PHP安装memcache扩展的方法:首先下载并解压缩memcache;然后根据实际情况使用phpize和php-config编译;接着通过make install进行安装;最后修改php.ini并重启php-fpm即可。
php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用
推荐:《PHP视频教程》
PHP 5.6.23,查询目前最稳定的版本是memcache-2.2.7。
1.下载并解压缩。
wget http://pecl.php.net/get/memcache-2.2.7.tgz
tar zxvf memcache-2.2.7.tgz
2. 编译。根据实际情况使用phpize和php-config。
[root@www memcache-2.2.7]# /usr/local/php/bin/phpizeConfiguring for:PHP Api Version: 20131106Zend Module Api No: 20131226Zend Extension Api No:220131226
登录后复制
[root@www memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config
登录后复制
3.安装。make;make install
[root@www memcache-2.2.7]# make installInstalling shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
登录后复制
4.修改php.ini(添加 extension=memcache.so)并重启php-fpm。
下面在linux下测试一下php与memcache的连接性。假设memcached服务器侧就在127.0.0.1。生成op_mem.php文件,代码如下:
<?php$memcache = new Memcache;$memcache->connect('127.0.0.1',11211) or die("Could not connect Mc server");$memcache->set('key','oldboy book');$get= $memcache->get('key');echo $get;?>
登录后复制
执行该文件,返回相应取值:
[root@www bbs]# /usr/local/php/bin/php op_mem.php oldboy book
登录后复制
以上就是PHP安装memcache扩展的方法的详细内容,更多请关注php中文网其它相关文章!