Linux环境Nginx安装多版本PHP

本文详细记录了在已安装PHP7.2.17的环境中,如何通过编译方式成功安装PHP5.6.40的过程,解决了配置过程中遇到的各种依赖问题。

因项目需要,今天在已经通过 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 <evp.h>
[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 <curl-dir>/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.youkuaiyun.com/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]

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值