以前在发表过一个编译PHP5.2.17的流程,写得比较乱,这次下单了vultr的VPS,特别编译了PHP5.2.17,使用Zend Optimizer v3.3.9,过程命令如下
安装最新版的NGINX
wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
sudo nano /etc/apt/sources.list
最后面添加NGINX源
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx
安装nginx
sudo apt-get update
sudo apt-get install nginx
安装相关的库文件
sudo apt-get install -y git autoconf lynx wget build-essential libxml2-dev libssl-dev libbz2-dev libcurl4-openssl-dev libpng12-dev libfreetype6-dev libxpm-dev libmcrypt-dev libmhash-dev libmysqlclient-dev libjpeg62-dev freetds-dev libjson-c-dev re2c
配置编译环境
sudo nano /etc/environment
添加
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
重启
sudo reboot
下载php5.2.17
sudo mkdir /opt/source
cd /opt/source
sudo wget -c http://museum.php.net/php5/php-5.2.17.tar.bz2
sudo tar xvjf php-5.2.17.tar.bz2
cd /opt/source/php-5.2.17
添加补丁
SimpleXML patch for PHP 5.2.17
sudo curl -o php-5.2.17.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
sudo patch -p0 -b < php-5.2.17.patch
PHP-FPM patch for PHP 5.2.17
sudo wget -c http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
sudo gunzip php-5.2.17-fpm-0.5.14.diff.gz
sudo patch -p1 < php-5.2.17-fpm-0.5.14.diff
OpenSSL Patch for PHP 5.2.17
sudo wget -c -t 3 -O ./debian_patches_disable_SSLv2_for_openssl_1_0_0.patch https://bugs.php.net/patch-display.php\?bug_id\=54736\&patch\=debian_patches_disable_SSLv2_for_openssl_1_0_0.patch\&revision=1305414559\&download\=1
sudo patch -p1 -b < debian_patches_disable_SSLv2_for_openssl_1_0_0.patch
Freetype support for PHP 5.2.17(仅适用于64位,32位系统不需要)
sudo mkdir -pv /usr/include/freetype2/freetype
sudo ln -sf /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h
编译安装PHP5.2.17
sudo ./configure -enable-cli -prefix=/opt/source/php-5.2.17 -with-pear -with-iconv -with-curl -with-mysqli -with-mysql -with-libdir=/lib/x86_64-linux-gnu -enable-mbstring -enable-exif -with-gd -with-jpeg-dir -with-freetype-dir -with-zlib -with-zlib-dir -with-gettext -with-mhash -enable-ftp -enable-bcmath -with-mime-magic -with-pdo-mysql -with-openssl -with-mcrypt -enable-sockets -enable-soap -enable-calendar -enable-fastcgi -enable-force-cgi-redirect -enable-fpm
sudo make
sudo make install
sudo cp /opt/source/php-5.2.17/php.ini-dist /opt/source/php-5.2.17/lib/php.ini
加PHP.INI,运行查看PHP版本
bin/php-cgi -v
返回即表示安装成功
PHP 5.2.17 (cgi-fcgi) (built: Jun 15 2017 07:54:11)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
配置FPM
sudo cp /opt/source/php-5.2.17/sapi/cgi/fpm/init.d/php-fpm.in /etc/init.d/php-fpm5217
sudo chmod +x /etc/init.d/php-fpm5217
sudo nano /etc/init.d/php-fpm5217
php_fpm_BIN=/opt/source/php-5.2.17/bin/php-cgi
php_fpm_CONF=/opt/source/php-5.2.17/etc/php-fpm.conf
php_fpm_PID=/opt/source/php-5.2.17/logs/php-fpm.pid
sudo nano /opt/source/php-5.2.17/etc/php-fpm.conf
127.0.0.1:9001
www-data
www-data
Unix user of processes
www-data
Unix group of processes
www-data
启动php-fpm进程
sudo service php-fpm5217 start
添加php-fpm自启动
sudo update-rc.d php-fpm5217 defaults
php5.2.17安装完成
请注意上面没有安装xcache,可以编译添加即可
编译安装xcache和openssl的文章请查看
https://www.mailshuxin.com/938/