Linux下php安装memcache扩展

安装环境:CentOS 6.4 

 

php扩展memcache的作用是为了支持memcached数据库缓存服务器,下面是安装方法。

 

1、下载

下载地址:http://pecl.php.net/package/memcache

文件名:memcache-3.0.8.tgz

文件下载成功后上传至/usr/local目录

 

2、安装

[[email protected] local]# tar -zxvf memcache-3.0.8.tgz
[email protected] local]# cd memcache-3.0.8
[[email protected] memcache-3.0.8]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[[email protected] memcache-3.0.8]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
[[email protected] memcache-3.0.8]# make
[[email protected] memcache-3.0.8]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
[[email protected] memcache-3.0.8]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20131226/

total 2140
-rwxr-xr-x. 1 root root 453766 Dec 30 17:44 memcache.so
-rwxr-xr-x. 1 root root 861055 Dec 30 16:47 redis.so

出现memcache.so就表明安装成功了

 

3、配置支持php

[[email protected] memcache-3.0.8]# vi + /usr/local/php/lib/php.ini
添加
extension=memcache.so
:wq! #保存退出

 

4、重启服务

[[email protected] memcache-3.0.8]# /usr/local/apache2/bin/apachectl restart

nginx服务器:

php5.3中要重启php-fpm,单纯的重启nginx不能使php.ini设置生效

[[email protected] memcached-2.2.0]#  service nginx restart 或者 /etc/init.d/nginx restart

[[email protected] memcached-2.2.0]#  service php-fpm restart 或者 /etc/init.d/php-fpm restart

 


查看phpinfo可以看到支持了

Linux下php安装memcache扩展