在https://pecl.php.net 上搜索memcached,能够找到两个memcached扩展:
memcache
主页:https://pecl.php.net/package/memcache
memcache已经很久没有更新了。
memcached
主页:https://pecl.php.net/package/memcached
php-memcached的github地址:https://github.com/php-memcached-dev/php-memcached
版本比较新,支持php7,使用了libmemcached库,推荐使用。
主页里有版本说明:
php-memcached 3.x:
支持的php版本: PHP 7.0 – 7.2;
libmemcached版本要求: libmemcached 1.x 或者更高;
php-memcached 2.x:
支持的php版本:PHP 5.2 – 5.6;
libmemcached版本要求:libmemcached 0.44 或者更高;
根据自己的php版本来选择合适的扩展版本。
memcached扩展的安装需要libmemcached,否则会报如下错误:
checking for libmemcached location… configure: error: memcached support requires libmemcached. Use –with-libmemcached-dir=
下载地址:https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
安装libmemcached
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -xzvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure
make
make install
完成之后会收到如下提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
安装memcached扩展:
wget https://pecl.php.net/get/memcached-2.2.0.tgz
tar -xzvf memcached-2.2.0.tgz
cd memcached-2.2.0
/usr/local/php/bin/phpize
./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config
make
make install
如果需要开启sasl,configure如下:
./configure –enable-memcache –enable-memcached-sasl –with-php-config=/usr/local/php/bin/php-config
找到php.ini文件:
locate php.ini
/root/php-5.6.14/php.ini-development
/root/php-5.6.14/php.ini-production
cp /root/php-5.6.14/php.ini-production /usr/local/php/etc/php.ini
修改php.ini配置文件
vim /usr/local/php/etc/php.ini
添加如下内容:
extension = memcached.so
重启php-fpm:
service php-fpm restart
可以看到,memcached扩展已经安装成功:
Sorry, the comment form is closed at this time.
No comments yet.