linux php-5.3.28版本升級到php-5.5.25

爲了方便,在linux環境下安裝了lnmp集成環境,但是後來在項目中,由於php5.3版本不支持數組以 ['a','b'] 的形式書寫,所以需要更新php到5.3以上版本。

lnmp中php是以config & make & make install 的方式安裝,所以卸載的話就直接停止php服務(service php-fpm stop 這裏啓動了php-fpm),再將安裝的php目錄(/usr/local/php,看phpinfo()裏都有信息)。

之後下載了最新的php-5.6.9.tar.gz,解壓後 ./configure 後面的參數由之前php-5.3.28的phpinfo()打印的./configure信息。

這樣./configure後會有警告,說 ‘--enable-magic-quotes’ 和 ‘--enable-safe-mode’不可用,原因是php-5.4之後就不支持,同樣去處的還有:'–enable-discard-path','–enable-fastcgi','–enable-force-cgi-redirect','–with-curlwrappers';

之後再make,又報錯:

/bin/bash /root/php-5.6.9/libtool --silent --preserve-dup-deps --mode=link cc -DPHP_ATOM_INC -I/root/php-5.6.9/include -I/root/php-5.6.9/main -I/root/php-5.6.9 -I/root/php-5.6.9/ext/date/lib -I/root/php-5.6.9/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/freetype2 -I/root/php-5.6.9/ext/mbstring/oniguruma -I/root/php-5.6.9/ext/mbstring/libmbfl -I/root/php-5.6.9/ext/mbstring/libmbfl/mbfl -I/usr/local/include -I/root/php-5.6.9/ext/sqlite3/libsqlite -I/root/php-5.6.9/ext/zip/lib -I/root/php-5.6.9/TSRM -I/root/php-5.6.9/Zend    -I/usr/local/include -g -O2 -fvisibility=hidden   -o ext/opcache/opcache.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/php-5.6.9/modules -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib ext/opcache/ZendAccelerator.lo ext/opcache/zend_accelerator_blacklist.lo ext/opcache/zend_accelerator_debug.lo ext/opcache/zend_accelerator_hash.lo ext/opcache/zend_accelerator_module.lo ext/opcache/zend_persist.lo ext/opcache/zend_persist_calc.lo ext/opcache/zend_shared_alloc.lo ext/opcache/zend_accelerator_util_funcs.lo ext/opcache/shared_alloc_shm.lo ext/opcache/shared_alloc_mmap.lo ext/opcache/shared_alloc_posix.lo ext/opcache/Optimizer/zend_optimizer.lo
libtool: link: `ext/opcache/zend_accelerator_blacklist.lo' is not a valid libtool object
make: *** [ext/opcache/opcache.la] Error 1

大概意思是說 xxx.lo不是有效的libtool object。

我想opcache是個php擴張,正常安裝的時候一般不會擴張出問題,很可能是php-5.6版本太新,我下載的安裝包有問題,所以就下了個php-5.5.25版本的試下。

果然按照之前的方式安裝下來能正常的make & make install。

安裝好php後試下php -v:

root@precise64:/usr/local/nginx/conf# php -v
Zend Guard Loader requires Zend Engine API version 220090626.
The Zend Engine API version 220121212 which is installed, is newer.
Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Guard Loader.

PHP 5.5.25 (cli) (built: May 20 2015 10:21:25)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

沒問題,php安裝成功。

接下來就是啓動php-fpm服務,service php-fpm start,報錯了,

root@precise64:~/php-5.5.25# service php-fpm start
Starting php-fpm [20-May-2015 10:23:40] ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
[20-May-2015 10:23:40] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
[20-May-2015 10:23:40] ERROR: FPM initialization failed
 failed

說是不能導入php-fpm.conf文件,先查下這個/usr/local/php/etc/php-fpm.conf是不是存在,沒有,就從原來的php-5.3.28中拷貝一份來,然後再啓動就ok了。

root@precise64:/usr/local/php/etc# service php-fpm start
Starting php-fpm Zend Guard Loader requires Zend Engine API version 220090626.
The Zend Engine API version 220121212 which is installed, is newer.
Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Guard Loader.

 done

查看下phpinfo()



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章