iiDBA 门户首页 技术文档 查看内容

CentOS安装两个版本PHP的方法

2020-6-4 01:59| 发布者: iidba| 查看: 938| 评论: 0

摘要: 刚在阿里云配置云主机,系统是CentOS,刚配置好了PHP7.2,朋友的站点上传上来,运行行情提示: 1522#0: *150 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function ...

刚在阿里云配置云主机,系统是CentOS,刚配置好了PHP7.2,朋友的站点上传上来,运行行情提示:[error] 1522#0: *150 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime(),需要PHP5.X,这时想到php-fpm多监听一个端口,是不是可以实现多版本PHP运行,网上一搜果然真有,便动手干起来

  1. wget下载php
  2. tar解压
  3. ./configure --prefix=/usr/local/php/php5445/ --with-fpm-user=nginx --with-fpm-group=nginx --enable-fpm --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --enable-pdo
  4. make && make test && make install,我这里make test是有错误的,但我也install了,也成功,没有时间去细究,先放这
  5. cd /安装目录/sbin,./php-fpm,提示[25-Aug-2019 10:43:45] ERROR: failed to open configuration file '/usr/local/php/php5445/etc/php-fpm.conf': No such file or directory (2),将php-fpm.conf.default复制一份,改名php-fpm.conf,vim php-fpm.conf,把user和group值改成nobody,监听端口改成9001
  6. 去nginx配置server,把需要用低版本PHP的server改下监听端口,fastcgi_pass 127.0.0.1:9001;
  7. 重启nginx
    大功告成


成功运行

最后再加一个开机启动启动
具体文章https://blog.csdn.net/it0_soft/article/details/88716639

  1. 进入目录cd /etc/init.d
  2. 新建文件vim /lib/systemd/system/php-fpm54.service,注意我这里名称加了版本号,以区别php7.2的php-fpm
[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
PrivateTmp=true
[Install]
WantedBy=multi-user.target
  1. 设置开机启动systemctl enable php-fpm54.service
  2. 重启一下netstat -ntpl查看是否9000和9001都在监听
9000和9001都在监听中

鲜花

握手

雷人

路过

鸡蛋
精彩评论

沙发等你来坐!

意见
反馈