解决军哥lnmp1.0默认安装后php从5.3.x升级到5.4.x后memcache.sh安装问题

lnmp1.0默认安装后php版本为5.3.17。升级php5.3.X和5.4.X后两种情况,再执行memcache.sh安装第一种没问题如下第一步骤,第二种会出现问题,则如下第二步骤解决:

一:如果想从php5.3.17升级为新版本5.3.x后,得重新安装memcache。

1.执行./upgrade_php.sh,输入5.3.x最新版,然后升级完毕。

2.然后执行memcache.sh安装完毕。ok,执行/root/lnmp restart,打开memcached.php测试OK:

Memcached Server version: 1.4.15
Get key1 value: This is first value
Get
key1 value: This is replace value
Get key2 value: Array ( [0] => aaa [1]
=> bbb [2] => ccc [3] => ddd )
Get key1 value:
Get key2 value:

二:如果想从php5.3.17升级为新版本5.4.x后,也得重新安装memcache。

1.执行./upgrade_php.sh,输入5.4.x最新版,然后升级完毕。

2.修改lnmp1.0-full包里的memcache.sh,找到:

printf “=========================== install memcached ======================n”

echo “Install memcache php extension…” wget -c http://soft.vpser.net/web/memcache/memcache-3.0.6.tgz tar zxvf memcache-3.0.6.tgz cd memcache-3.0.6/ /usr/local/php/bin/phpize ./configure –with-php-config=/usr/local/php/bin/php-config make && make install cd ../

修改为:

printf “=========================== install memcached ======================n”

echo “Install memcache php extension…” wget -c http://pecl.php.net/get/memcache-3.0.8.tgz tar zxvf memcache-3.0.8.tgz cd memcache-3.0.8/ /usr/local/php/bin/phpize ./configure –with-php-config=/usr/local/php/bin/php-config make && make install cd ../

然后上传保存,权限改为0755

3.最后执行memcache.sh安装完毕。ok,执行/root/lnmp restart,打开memcached.php测试OK:

Memcached Server version: 1.4.15 Get key1 value: This is first value Get key1 value: This is replace value Get key2 value: Array ( [0] => aaa [1] => bbb [2] => ccc [3] => ddd ) Get key1 value: Get key2 value:

总结:编译PHP5.4.x使用的PHP核心版本是20100525,而军哥lnmp1.0中Memcache-3.0.6是使用20090626版本编译的,版本不一致导致PHP无法启用memcache.so库,故改为Memcache-3.0.8,最后生产环境目前还是不要升级到php5.5.X版本!

 

PHP5.4.x和Memcache的版本不兼容问题

下载目前最新的PHP5.4.8编译后(fpm),使用sudo apt-get install memcached安装memcache服务,再使用Pecl:http://www.ln.la/473/pecl-pear-php-extensions.html安装memcache(sudo pecl install memcache)PHP扩展,编译后memcache.so在/usr/lib/php5/20090626/中,在PHP.ini添加好extension,重启phpfpm(不是重启nginx),出现下面的错误信息:

1 Gracefully shutting down php-fpm . done

2 Starting php-fpm [25-Oct-2012 12:04:02] NOTICE:

3 PHP message: PHP Warning: PHP Startup: memcache: Unable to initialize module

4 Module compiled with module API=20090626

5 PHP compiled with module API=20100525

6 These options need to match

继续阅读PHP5.4.x和Memcache的版本不兼容问题