在同一服务器上运行两个PHP版本(STRETCH) [英] Running two PHP versions on the same server (STRETCH)

查看:185
本文介绍了在同一服务器上运行两个PHP版本(STRETCH)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照本教程在服务器上安装了php 5.6和php 7:
在同一服务器上运行两个PHP版本

I've followed this tutorial to have php 5.6 and php 7 on my server : Running two PHP versions on the same server

问题是我在Debian 9上运行Stretch和模块fastcgi不再可用。有proxy_fcgi,但其中不包含 FastCgiExternalServer 。我已经读了很多东西,但是我不知道该如何替换......知道吗?

The thing is that I'm running on Debian 9 Stretch and the module fastcgi is not available anymore. There's proxy_fcgi but it doesn't include FastCgiExternalServer. I've read many things but I can't figure out how to replace it... Any idea ?

<ifModule mod_proxy_fcgi.c>
   AddHandler php56-fcgi .php
   Action php56-fcgi /php56-fcgi
   Alias /php56-fcgi /usr/lib/cgi-bin/php56-fcgi
   FastCgiExternalServer /usr/lib/cgi-bin/php56-fcgi -socket /var/run/php/php5.6-fpm.sock -pass-header Authorization
   Action php70-fcgi /php70-fcgi
   Alias /php70-fcgi /usr/lib/cgi-bin/php70-fcgi
   FastCgiExternalServer /usr/lib/cgi-bin/php70-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization
</IfModule>
<Directory /usr/lib/cgi-bin>
   Require all granted
</Directory>`


推荐答案

花了我一段时间才能弄清楚该怎么做,但最后我找到了一个简单的解决方案:

It took me a while to figure out what to do but at the end I found an easy solution :

sudo apt-get install php5.6-fpm

sudo apt-get install php7.0-fpm

sudo a2enconf php5.6-fpm

如果已安装php5.6和php5.7,请确保禁用这两个功能并重新启动apache。

If you installed php5.6 and php5.7, make sure you disable this two and restart apache.

sudo a2dismod php5.6 php7.0

sudo systemctl restart apache2

至此,所有站点都必须在php 5.6上运行。

At this point all of your sites must work on php 5.6.

对于需要php 7的网站,在虚拟主机中添加以下行:

For the sites who need php 7, add this line in the vhost :

ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/var/run/php/php7.0-fpm.sock|fcgi://localhost/path/to/my/main/file"

它应该可以解决问题:)

It should do the trick :)

这篇关于在同一服务器上运行两个PHP版本(STRETCH)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆