Linux环境Nginx安装多版本PHP

因项目需要,今天在已经通过 yum 安装 PHP 7.2.17环境下,在安装一个PHP 5.6.40,使得环境满足多版本PHP

而这个PHP 5.6.40 只能通过编译安装了,用惯了yum,编译安装真是让人保持心态平和,折腾了一天,终于成功。

关键命令:

[root@iZbp1319y2gcmn0mb0l7j8Z ~]# wget https://www.php.net/distributions/php-5.6.40.tar.gz
[root@iZbp1319y2gcmn0mb0l7j8Z ~]# tar -zxvf php-5.6.40.tar.gz 
[root@iZbp1319y2gcmn0mb0l7j8Z ~]# cd php-5.6.40

[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# ./configure --prefix=/usr/local/php56 --with-config-file-path=/usr/local/php56/etc --enable-fpm --with-bz2 --with-gd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-zlib-dir --with-iconv-dir=/usr/local --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-curl --enable-bcmath --enable-sockets --enable-calendar --with-gettext --with-pdo-mysql=mysqlnd --disable-fileinfo --with-ldap --with-openssl --with-pear --with-xmlrpc --enable-gd-native-ttf 


[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install libxml2-devel

configure: error: Cannot find OpenSSL's 
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install openssl openssl-devel

configure: error: Please reinstall the BZip2 distribution
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install bzip2 bzip2-devel -y

configure: error: Please reinstall the libcurl distribution -
    easy.h should be in /include/curl/
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install curl curl-devel -y

configure: error: jpeglib.h not found.
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum -y install libjpeg-devel

configure: error: png.h not found.
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install libpng libpng-devel -y

configure: error: freetype-config not found.
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install freetype-devel -y

configure: error: Cannot find ldap.h
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install openldap-devel -y

configure: error: Cannot find ldap libraries in /usr/lib.
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# find / -name libldap*
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# cp -frp /usr/lib64/libldap* /usr/lib/

configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# yum install -y libmcrypt-devel

https://blog.csdn.net/kajweb/article/details/80211322
Makefile
找到 开头是 ‘EXTRA_LIBS’ 这一行 在结尾加上 ‘-llber’ 然后执行 make && make install

vi Makefile
/^EXTRA_LIBS
行尾加上 “-llber”,存盘退出
[root@iZbp1319y2gcmn0mb0l7j8Z php-5.6.40]# make && make install

 php-fpm常用命名:

# 查看 php-fpm 用户
ps aux | grep php-fpm
 
# 查看 php-fpm 进程 pid
ps -ef | grep php-fpm
 
# 启动 php-fpm
php-fpm -D
 
# 关闭 php-fpm
kill -INT [pid]
 
# 重启 php-fpm
kill -USR2 [pid]

 

你可能感兴趣的:(PHP,nginx,Server,PHP,编译,多版本,Linux,Nginx)