linux下 手动安装php memcache扩展,配合php-fpm nginx

当然有不少办法可以安装memcache的插件不过如果你使用了php-fpmnginx驱动php采用那些sudo apt-get install php5-memcache可能就不好用了。
说说如果你把php手动安装在特别目录的情况下如何配置memcache php调用吧。

上下文参考我写的php-fpm安装那篇博客吧。

cd /data1/server/php-cgi/bin

进入php安装好的目录bin下执行
./pecl install memcache
downloading memcache-2.2.6.tgz …
Starting to download memcache-2.2.6.tgz (35,957 bytes)
……….done: 35,957 bytes
11 source files, building
WARNING: php_bin /data1/server/php-cgi/bin/php appears to have a suffix -cgi/bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize’ failed

少个东西没装啊。开始装他
sudo apt-get install autoconf

显示出成功了。

Build process completed successfully
Installing ‘/data1/server/php-cgi/lib/php/extensions/no-debug-non-zts-20100525/memcache.so’
install ok: channel://pecl.php.net/memcache-2.2.6
configuration option “php_ini” is not set to php.ini location
You should add “extension=memcache.so” to php.ini

安装提示把extension=memcache.so 这句话加入php.ini就成功了。
测试一下

<?php
$mem = new Memcache;
$mem->connect(‘211.144.xx.xx’, 11211);
$mem->set(‘key’, ‘This is a test!’, 0, 60);
$val = $mem->get(‘key’);
echo $val;
?>

是不是成功了。


This entry was posted in Linux, PHP, 高并发与大数据 and tagged , , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/php-memcache-intall-fpm/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

  

  

About Me

静水流深,水滴石穿