升级
目前php最新版虽然是php5.5,但出于各种考虑,还是先升到php5.4比较靠谱。
原php使用的是php5.2.10,已经运行了4~5年了,是时候升级了。
5.4最新稳定版是5.4.21(14 Nov 2013发布了5.4.22...)
复制代码 代码如下:
wget http://cn2.php.net/get/php-5.4.21.tar.gz/from/this/mirror
tar zxf php-5.4.21.tar.gz
cd php-5.4.21
修改源码,如果程序编码是utf-8的,跳过此步骤。
如果你的程序默认是GBK,而且程序中有不少使用htmlspecialchars的,建议直接修改源码,因为5.4默认为utf-8了。用htmlspecialchars输出的都会是空。
复制代码 代码如下:
ext/standard/html.c
line 372
if (charset_hint == NULL)
return cs_utf_8;
--->
if (charset_hint == NULL)
return cs_8859_1;
解决htmlspecialchars默认UTF-8的问题。
复制代码 代码如下:
./configure --prefix=/usr/local/php5.4 --with-zlib --enable-bcmath --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --with-pdo-mysql --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=ments=0
opcache.enable_file_override=1
service php-fpm reload
这里phpinfo()里就有with Zend OPcache v7.0.2,以及不少相关的参数了。
这样php5.4就算升级完了。
--------------------------------
可能碰到的错误:
启动php-fpm失败
复制代码 代码如下:
Starting php-fpm /etc/init.d/php-fpm: line 53: 12483 Segmentation fault $php_fpm_BIN --daemonize $php_opts
failed
同时安装了APC和Zend opcache导致冲突,有了Zend opcache,可以不用装APC了。