Linux服务器上安装PHP5.2.17和php5.6.38

时间:2024-04-06 20:34:19

**

同一台机器上安装PHP5.2.17和php5.6.38

**
本文使用的服务器环境为(Centos 6.8 64bit)

1、安装tengine-2.2.0
1)下载源码包wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
2)编译安装 tar -zxvf tengine-2.2.0.tar.gz
Cd tengine-2.2.0
先安装依赖包 yum -y install openssl openssl-devel pcre pcre-devel gd gd-devel
编译 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_concat_module --with-pcre
安装:make && install

3)添加用户组/usr/sbin/groupadd -f www
4)添加用户/usr/sbin/useradd -s /sbin/nologin -g www www
5)/usr/local/sbin/nginx -s start

2、先安装常用php版本(5.6.38)
1)下载源码包wget http://am1.php.net/distributions/php-5.2.17.tar.gz
2)安装依赖yum -y install gcc gcc-c++ make automake autoconf
yum -y install libxml2-devel openssl-devel pcre-devel sqlite-devel bzip2-deve llibcurl-devel freetype-devel gd-devel readline-devel libmcrypt-devel libcurl-devel libxslt libxslt-devel
3)编译./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-curl=/usr/local/lib --with-freetype-dir=/usr/lib64 --with-gd --with-gettext --with-iconv-dir=/usr/local/lib --with-jpeg-dir=/usr/lib64 --with-kerberos --with-libdir=lib64 --with-libxml-dir=/usr/lib64 --with-mcrypt --with-mhash --with-mysql --with-mysqli --with-openssl --with-pcre-regex=/usr --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pear=/usr/local/lib/php --with-png-dir=/usr/lib64 --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip --disable-rpath
4)安装make && make install
5)启动php-fpm
/usr/local/php/sbin/php-fpm

3、安装低版本PHP(5.2.17)
1)下载源码包 cd /usr/local/src/
wget http://soft.7dot.com/soft/php-5.2.17.tar.gz
2)下载php-fpm源码包:
wget -c http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
3)解压tar -zxvf 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
Cd php-5.2.17
4)安装依赖 yum install libjpeg-devel
mysql-client库链接 ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib/libmysqlclient.so
5)./configure --prefix=/usr/local/php52 --enable-fastcgi --enable-zip --enable-fpm --enable-gd-native-ttf --with-config-file-path=/usr/local/php52/etc --with-config-file-scan-dir=/usr/local/php52/etc/php.d --with-curl --with-libxml-dir=/usr/lib64 --with-gd --with-jpeg-dir --with-freetype-dir=/usr/lib64 --with-png-dir --with-mcrypt --with-mhash --enable-mbstring --with-kerberos --with-gettext --enable-bcmath --with-mysql --with-mysqli --with-sqlite --enable-pdo --with-pdo-mysql --with-openssl --enable-ftp --with-pear --with-zlib --enable-inline-optimization --enable-calendar --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --disable-debug
Linux服务器上安装PHP5.2.17和php5.6.38
出现上面显示表示成功。
6)安装make && make install
Linux服务器上安装PHP5.2.17和php5.6.38
出现上面显示表示成功。
7)Vim /usr/local/php52/etc/php-fpm.conf
Linux服务器上安装PHP5.2.17和php5.6.38
将127.0.0.1:9000改成127.0.0.1:9052,将注释去掉,将nobody换成www。
Linux服务器上安装PHP5.2.17和php5.6.38
8)启动php-fpm
/usr/local/php/sbin/php-fpm

4、测试访问,修改tengine配置 vim /usr/local/nginx/conf/nginx.conf
Linux服务器上安装PHP5.2.17和php5.6.38
去掉该段注释。
在下面添加一段server
Linux服务器上安装PHP5.2.17和php5.6.38
启动nginx /usr/local/nginx/sbin/nginx -s start
创建测试文件vim /usr/local/nginx/html/info.php
Linux服务器上安装PHP5.2.17和php5.6.38

访问结果
5.6.38:
Linux服务器上安装PHP5.2.17和php5.6.38
5.2.17:
Linux服务器上安装PHP5.2.17和php5.6.38