现在的位置: 首页 > 综合 > 正文

安装Memcached和Memcached PHP扩展

2018年11月04日 ⁄ 综合 ⁄ 共 1310字 ⁄ 字号 评论关闭

Memcached资源很容易混淆,所以我打包好了.

下载地址: http://www.euphie.net/downloads/memcached.tar.gz

下载后解压,里面有几个包:

1.memcached-1.4.15 //Memcached服务端.

2.memcached-2.1.0 //PHP的Memcached扩展,其实Memcached扩展有两种,还有一种叫Memcache,不过Memcached比Memcache功能更强大.

3.libevent-2.0.21-stable //Memcached服务端的依赖包.

4.libmemcached-1.0.16 //Memcached扩展的依赖包.

一,安装Libevent

#cd libevent-2.0.21-stable
#./configure -prefix=/usr/local/libevent
#make
#make install

二,安装Memcached服务端

#cd memcached-1.4.15
#./configure -prefix=/usr/local/memcached 
-with-libevent=/usr/local/libevent
#make
#make install

三,启动Memcached服务

#/usr/local/memcached/bin/memcached -d -m 50 
-u root -p 12000 -c 256 -P /tmp/memcached.pid

注:
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB.
-u是运行Memcache的用户.
-l是监听的服务器IP地址,我这里没有填.
-p是设置Memcache监听的端口.
-c选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定.
-P是设置保存Memcache的pid文件.

四,安装Libmemcached

#cd libmemcached-1.0.16
#./configure -prefix=/usr/local/libmemcached 
-with-memcached=/usr/local/memcached/bin/memcached
#make
#make install

注:
如果报”./libmemcached-1.0/memcached.h:46:27: error: tr1/cinttypes: No such file or directory”错误,则需要升级gcc版本.

五,安装Memcached PHP扩展

#cd memcached-2.1.0
找到phpize和php-config的路径,我的分别是/usr/local/bin/phpize和/usr/bin/php-config.
#/usr/local/bin/phpize
#./configure --with-php-config=/usr/bin/php-config 
--with-libmemcached-dir=/usr/local/libmemcached
#make
#make install
安装成功后会生成memcached.so,把路径加到php.ini的extension=xxx里.

抱歉!评论已关闭.