1. 程式人生 > >Linux伺服器上安裝PHP5.2.17和php5.6.38

Linux伺服器上安裝PHP5.2.17和php5.6.38

**

同一臺機器上安裝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 在這裡插入圖片描述

出現上面顯示錶示成功。 6)安裝make && make install 在這裡插入圖片描述 出現上面顯示錶示成功。 7)Vim /usr/local/php52/etc/php-fpm.conf 在這裡插入圖片描述 將127.0.0.1:9000改成127.0.0.1:9052,將註釋去掉,將nobody換成www。 在這裡插入圖片描述 8)啟動php-fpm /usr/local/php/sbin/php-fpm

4、測試訪問,修改tengine配置 vim /usr/local/nginx/conf/nginx.conf 在這裡插入圖片描述 去掉該段註釋。 在下面新增一段server 在這裡插入圖片描述 啟動nginx /usr/local/nginx/sbin/nginx -s start 建立測試檔案vim /usr/local/nginx/html/info.php 在這裡插入圖片描述

訪問結果 5.6.38: 在這裡插入圖片描述 5.2.17: 在這裡插入圖片描述