PHP無痛升級
PHP其實滿久才更新一次的,這次的5.3.9是因為安全性的修正(Hash計算引起的DDoS攻擊),詳細可以參考官網的更新紀錄,但對手動鞭譯的人還滿討厭的,因為都已經上線運作了還得暫停來搞,我的想法是儘速更新完就好了,畢竟買便宜的VPS沒太多資源搞雙機運作還啥的方案,乾脆早死早超生~ 趕快弄一弄就好了。
Step.1:停止相關服務來下載新版PHP安裝並備份原設定檔
/etc/init.d/mysql stop
/etc/init.d/nginx stop
/etc/init.d/php-fpm stop
cp /usr/local/php/etc/php.ini /usr/local/php.ini.bak
cp /usr/local/php/etc/php-fpm.conf /usr/local/php-fpm.conf.bak
rm -rf /usr/local/php
cd /usr/src/
wget http://us2.php.net/distributions/php-5.3.9.tar.bz2
tar jxf php-*.tar.bz2
cd php-*
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-bcmath --enable-calendar --enable-dba --enable-exif --enable-fpm --enable-ftp --enable-gd-jis-conv --enable-gd-native-ttf --enable-inline-optimization --enable-mbstring --enable-mbregex --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvshm --enable-sysvsem --enable-xml --enable-wddx --enable-zip --with-bz2 --with-curl --with-curlwrappers --with-freetype-dir --with-fpm-user=www --with-fpm-group=www --with-gd --with-gettext --with-iconv-dir=/usr/local/libiconv --with-jpeg-dir --with-libxml-dir --with-mcrypt --with-mhash --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-png-dir --with-openssl --with-t1lib=/usr/share/t1lib --with-xmlrpc --with-xpm-dir --with-xsl --with-zlib
make && make install
/usr/src/php-*/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -f -s /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
ln -f -s /usr/local/php/bin/pear /usr/bin/pear
ln -f -s /usr/local/php/bin/peardev /usr/bin/peardev
ln -f -s /usr/local/php/bin/pecl /usr/bin/pecl
ln -f -s /usr/local/php/bin/php /usr/bin/php
ln -f -s /usr/local/php/bin/php-cgi /usr/bin/php-cgi
ln -f -s /usr/local/php/bin/php-config /usr/bin/php-config
ln -f -s /usr/local/php/bin/phpize /usr/bin/phpize
cd ..
Step.2:安裝eAccelerator
如果更新完就執行的話一定會碰到如圖片下方Unable to load dynamic library的錯誤訊息,所以要重新安裝AceLNMP相關的PHP外掛模組eAccelerator。
cd /usr/src/
wget http://sourceforge.net/projects/eaccelerator/files/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.tar.bz2
tar jxf eaccelerator-*.tar.bz2
cd eaccelerator-*
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ..
mkdir -p /tmp/eaccelerator_cache
chmod -R 777 /tmp/eaccelerator_cache
cd /usr/src/
rm -fr eaccelerator-*
Step.3:安裝imagick
cd /usr/src/
wget http://pecl.php.net/get/imagick-3.0.1.tgz
tar zxf imagick-*.tgz
cd imagick-*
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd /usr/src/
rm -fr imagick-*
Step.4:安裝PDO_MYSQL
cd /usr/src/
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar zxf PDO_MYSQL-*.tgz
cd PDO_MYSQL-*
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make && make install
cd /usr/src/
rm -fr PDO_MYSQL-*
Step.5:安裝memcache
cd /usr/src/
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar zxf memcache-*.tgz
cd memcache-*
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd /usr/src/
rm -fr memcache-*
Step.6:全部搞定,啟動相關服務並刪除殘留檔案,花費時間不到10分鐘
cd /usr/src/
rm -fr php-*
rm -f package2.xml package.xml
/etc/init.d/mysql start
/etc/init.d/nginx start
/etc/init.d/php-fpm start
php -v



文章不错,来看看