刚在阿里云配置云主机,系统是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运行,网上一搜果然真有,便动手干起来
- wget下载php
- tar解压
- ./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
- make && make test && make install,我这里make test是有错误的,但我也install了,也成功,没有时间去细究,先放这
- 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
- 去nginx配置server,把需要用低版本PHP的server改下监听端口,fastcgi_pass 127.0.0.1:9001;
-
重启nginx
大功告成
成功运行
最后再加一个开机启动启动
具体文章https://blog.csdn.net/it0_soft/article/details/88716639
- 进入目录
cd /etc/init.d
- 新建文件
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
- 设置开机启动
systemctl enable php-fpm54.service
- 重启一下
netstat -ntpl
查看是否9000和9001都在监听
9000和9001都在监听中
网友评论