思路:
下載不同的php源碼包,解壓后安裝在不同的目錄下,修改php-fpm監聽的端口號
php安裝配置參數:
./configure --prefix=/usr/local/php71 --exec-prefix=/usr/local/php71 --bindir=/usr/local/php71/bin --sbindir=/usr/local/php71/sbin --includedir=/usr/local/php71/include --libdir=/usr/local/php71/lib/php --mandir=/usr/local/php71/php/man --with-config-file-path=/usr/local/php71/etc --with-mcrypt=/usr/local/libmcrypt --with-mhash --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-gd --with-iconv --with-zlib --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-fpm --without-gdbm --disable-fileinfo --enable-opcache=no
make && make install
運行 /usr/local/php71/sbin/php-fpm 報錯如下:
原因:php-fpm.conf 文件不存在
解決:
修改www.conf文件,修改php-fpm監聽的端口號 改為9001
啟動php-fpm,結果如下,成功了,系統運行了兩個版本的php
最后,可以將新版本的php加入開機自啟動,修改 /etc/rc.local文件,加入php-fpm的運行路徑即可