问题
I've followed this tutorial to have php 5.6 and php 7 on my server : Running two PHP versions on the same server
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>`
回答1:
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
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
At this point all of your sites must work on php 5.6.
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 :)
来源:https://stackoverflow.com/questions/46845963/running-two-php-versions-on-the-same-server-stretch