所需软件
libevent-2.0.6-rc.tar.gz (http://monkey.org/~provos/libevent/)
memcache-2.2.5.tgz (http://pecl.php.net/package/memcache) 用于安装php的扩展
memcached-1.4.0.tar.gz (http://www.danga.com/memcached/)
libevent-2.0.6-rc.tar.gz (http://monkey.org/~provos/libevent/)
memcache-2.2.5.tgz (http://pecl.php.net/package/memcache) 用于安装php的扩展
memcached-1.4.0.tar.gz (http://www.danga.com/memcached/)
下载后全部放置在/var/software/下
tar zxvf 解压缩有文件
1.首先安装libevent,不然memcached可是不能装的
cd libevent-2.0.6-rc
./configure --prefix=/usr/local/libevent
make
make install
2.接着安装memcached
cd memcached-1.4.0
./configure --prefix=/usr/local/memcached -width-libevent=/usr/local/libevent
make
make install
3.启动memcached
/usr/local/servers/memcached -d -m 128 -l localhost -p 11211 -u root
-d 以守护程序(daemon)方式运行 memcached;
-m 设置 memcached 可以使用的内存大小,单位为 M;
-l 设置监听的 IP 地址,如果是本机的话,通常可以不设置此参数;
-p 设置监听的端口,默认为 11211,所以也可以不设置此参数;
-u 指定用户;
启动会遇到问题:error while loading shared libraries: libevent-2.0.so.2: cannot open shared object file: No such file or directory
别人说要这么干
-
则运行 LD_DUBUG=libs 就可以知道memcached启动时库的加载路径。具体如下:
-
-
# LD_DEBUG=libs /usr/local/servers/memcached/bin/memcached -v
-
10929: find library=libevent-1.4.so.2 [0]; searching
-
10929: search cache=/etc/ld.so.cache
-
10929: search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib (system search path)
-
10929: trying file=/lib/tls/i686/sse2/libevent-1.4.so.2
-
10929: trying file=/lib/tls/i686/libevent-1.4.so.2
-
10929: trying file=/lib/tls/sse2/libevent-1.4.so.2
-
10929: trying file=/lib/tls/libevent-1.4.so.2
-
10929: trying file=/lib/i686/sse2/libevent-1.4.so.2
-
10929: trying file=/lib/i686/libevent-1.4.so.2
-
10929: trying file=/lib/sse2/libevent-1.4.so.2
-
10929: trying file=/lib/libevent-1.4.so.2
-
10929: trying file=/usr/lib/tls/i686/sse2/libevent-1.4.so.2
-
10929: trying file=/usr/lib/tls/i686/libevent-1.4.so.2
-
10929: trying file=/usr/lib/tls/sse2/libevent-1.4.so.2
-
10929: trying file=/usr/lib/tls/libevent-1.4.so.2
-
10929: trying file=/usr/lib/i686/sse2/libevent-1.4.so.2
-
10929: trying file=/usr/lib/i686/libevent-1.4.so.2
-
10929: trying file=/usr/lib/sse2/libevent-1.4.so.2
-
10929: trying file=/usr/lib/libevent-1.4.so.2
-
10929:
-
-
然后给libevent-1.4.so.2建立一个链接后再运行memcached:
-
# ln -s /usr/local/servers/libevent/lib/libevent-1.4.so.2 /lib/libevent-1.4.so.2
但是我的机器不好使,直接ln -s /usr/local/servers/libevent/lib/libevent-2.0.so.2 /lib/libevent-2.0.so.2
4.安装php memcache扩展
可以使用php自带的pecl安装程序
# /usr/local/servers/php5/bin/pecl install memcache
cd memcache-2.2.5
/usr/local/php/bin/phpize
./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir
make
make install
上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
找到php.ini 我的在/uar/local/php/lib/下面(其实是个软连接,指向:/usr/local/Zend/etc/php.ini)
把php.ini中的extension_dir = “./”修改为
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”
添加一行来载入memcache扩展:extension=memcache.so
然后service httpd stop
然后查看phpinfo();
如有即可
(责任编辑:IT) |