如何设置lnmp可以切换php版本

2017-07-04 16:52:21 12307

1.       说明:linux下安装lnmp的默认php版本只能使用一个版本,如果有些网站需要低版本5.2或者高版本,那么如何做呢,

2.       Lnmp安装时候默认选择了php5.3,但是其中某个网站需要php5.5

3.       编译安装php5.5

(a)安装必要软件

rpm -ivh http://www.landui.com/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum groupinstall 'Development Tools'

yum install libmhash-devel

yum install libmhash

yum install libicu-devel

yum -y install krb5*

yum install -y gcc gcc-c++ make gmp-devel libc-client-devel zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

(b)安装libiconv

wget http://www.landui.com/pub/gnu/libiconv/libiconv-1.14.tar.gz

./configure --prefix=/usr/local/libiconv

make && make install

(c)安装libmcrypt

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt

tar zxvf libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7

./configure

make && make install
(d)如果是64为操作系统执行以下操作

ln -s /usr/lib64/libc-client.so  /usr/lib/libc-client.so   

cp -frp /usr/lib64/libldap* /usr/lib/                       

ln -s /usr/lib64/libpng.so /usr/lib/libpng.so               

ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so 

ln -s /usr/lib64 /usr/kerberos/lib

cp -r /usr/lib64/mysql/* /usr/lib/mysql/

(e)下载php5.5编译安装

wget http://www.landui.com/distributions/php-5.5.38.tar.gz

tar –zxvf php-5.5.38.tar.gz

cd php-5.5.38

先生成Makefile:

./configure --prefix=/usr/local/php5.5 --with-config-file-path=/usr/local/php5.5/etc --with-config-file-scan-dir=/usr/local/php5.5/php.d --with-mysql --with-mysqli --with-iconv-dir=/usr/local/libiconv --with-mhash=/usr --with-icu-dir=/usr --with-bz2 --with-curl --with-freetype-dir --with-gd --with-gettext --with-gmp --with-imap --with-imap-ssl --with-jpeg-dir --with-kerberos --with-ldap --with-mcrypt --with-openssl --without-pear --with-pdo-mysql --with-png-dir --with-xmlrpc --with-zlib --enable-bcmath --enable-calendar --enable-ctype --enable-dom --enable-exif --enable-ftp --enable-gd-native-ttf --enable-intl --enable-json --enable-mbstring --enable-pcntl --enable-session --enable-shmop --enable-simplexml --enable-soap --enable-sockets --enable-tokenizer --enable-wddx --enable-xml --enable-zip --disable-fileinfo --enable-fpm

开始编译和安装

make && make install

cp php.ini-production /usr/local/php5.5/etc/php.ini

(f)添加php5.5到服务项并设置自动启动:

cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php5.5

chmod +x /etc/init.d/php5.5

cd /usr/local/php5.5/etc/

cp php-fpm.conf.default php-fpm.conf

vi php-fpm.conf 修改监听端口listen 127.0.0.1:9000listen 127.0.0.1:9001

chkconfig php5.5 on

service php5.5 start

(g)建立新文件/usr/local/nginx/conf/enable-php5.5.conf,内容如下:

image.png

(h)最后修改需要php5.5版本的网站配置文件如,www.landui.com
修改include enable-php.conf;include enable-php5.5.conf;
image.png

(i)重启nginx

image.png

提交成功!非常感谢您的反馈,我们会继续努力做到更好!

这条文档是否有帮助解决问题?

非常抱歉未能帮助到您。为了给您提供更好的服务,我们很需要您进一步的反馈信息:

在文档使用中是否遇到以下问题: