在Debian 8 系统里编译安装php5.2
目的:在Debian 8 系统里安装php5.2,以支持需要php Zend Optimizer 运行环境的程序。
Debian 8 自带的php版本是php5.6,如此配置后,可为指定的站点使用php5.2.17版本。
过程:
1.下载php5.2.17源码,php-fpm补丁:
wget http://museum.php.net/php5/php-5.2.17.tar.gz
wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
2.解压php5.2.17源码包,且打好php-fpm补丁:
tar -xvzf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
3.转到php5.2.17的目录,下载php5.2的xml补丁,打上:
cd php-5.2.17
wget https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
patch -p0 -b < txtbgxGXAvz4N.txt
4.安装相关的开发组件包,编译,并安装:
apt-get install libxslt-dev libz-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libmcrypt-dev libmysqlclient-dev libmhash-dev libltdl-dev
./configure --prefix=/usr/local/php-5.2.17 --with-config-file-path=/usr/local/php-5.2.17/etc --enable-fastcgi --enable-fpm --with-libdir=lib/x86_64-linux-gnu --with-mcrypt --enable-mbstring --enable-pdo --with-curl --disable-debug --enable-xml --with-zlib --enable-sockets --with-mhash --with-gd --with-pdo-mysql --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-mysql --with-mysqli
make
make install
5.根据编译时写好的安装路径,调整php-fpm的运行参数,如修改运行用户和用户组,将 php-fpm.conf 的 “Unix user of processes” 和 “Unix group of processes” 代码注释删除,且添加好www-data用户及组
vi /usr/local/php-5.2.17/etc/php-fpm.conf
6.复制php.ini文件到php-fpm的路径:
cp php.ini-recommended /usr/local/php-5.2.17/etc/php.ini
7.下载、解压 Zend Optimizer
wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
tar xzvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
8.复制 ZendOptimizer.so 到相应的扩展目录:
mkdir -p /usr/local/php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613
cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613
9.在 php.ini 里添加一行:
zend_extension=/usr/local/php-5.2.17/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer.so
10.启动 php-fpm 服务:
/usr/local/php-5.2.17/sbin/php-fpm start
11.在nginx的站点配置中配置相应的php-fpm信息:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
}
}
参考: