问题描述
我需要在Ubuntu 14.04机器上并行运行带有mod_php的PHP 5.6和带有php-fpm/mod-fastcgi的PHP 7.2.在装有Ubuntu 16.04,Apache 2.4和PHP 7.1/mod_php和PHP 7.2/php-fpm的另一台计算机上,所有操作均按预期进行.我的步骤:
I need to run PHP 5.6 with mod_php and PHP 7.2 with php-fpm/mod-fastcgi parallel on a Ubuntu 14.04 machine.On a different machine with Ubuntu 16.04, Apache 2.4 and PHP 7.1/mod_php and PHP 7.2/php-fpm everything works as expected.My steps:
apt install libapache2-mod-fastcgi php7.2-fpm php7.2 php7.2-common
a2enmod actions fastcgi alias proxy_fcgi
我用不同的池名称,用户名和组,套接字文件/var/run/php/php7.2-fpm-mysite.sock设置了一个fpm conf文件.服务php7.2-fpm启动并创建套接字文件.虚拟主机的Docroot所有者设置为fmp conf文件中给定的用户名和组.我将以下行添加到虚拟主机:
I set up an fpm conf file with a different pool name, username and group, socket file /var/run/php/php7.2-fpm-mysite.sock.Service php7.2-fpm is started and the socket file is created.Docroot owner for the virtual host is set to the username and group given in the fmp conf file.I added the follwoing lines to the virtual host:
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php/php7.2-fpm-mysite.sock|fcgi://localhost/"
</FilesMatch>
在Ubuntu 16.04计算机上,一切正常.一个虚拟主机正在使用php-fpm 7.2,其他所有站点仍在使用php_mod 7.1.
On the Ubuntu 16.04 machine, everything works fine. The one virtual host is using php-fpm 7.2, all other sites are still using the php_mod 7.1.
然后,我在Ubuntu 14.04计算机上重复了所有这些步骤.我没有任何错误,但是在浏览网页时,PHP代码以纯色打印.该代理显然不能正常工作,但我不知道为什么.套接字文件已创建,php-fpm日志中没有错误.装有mod_php 5.6的Ubuntu 14.04计算机上的所有其他页面均按预期工作.在此先感谢您的帮助.如果需要,我可以提供更多配置.
Then I repeated all these steps on the Ubuntu 14.04 machine. I had no errors, but when browsing a web page, the PHP code is printed in plain.The proxy is not working obviously, but I have no idea why. Socket file is created, no errors in php-fpm log.All other pages on the Ubuntu 14.04 machine with mod_php 5.6 are working as expected.Thanks in advance for any help. I can provide more config if needed.
最诚挚的问候马赛厄斯
Best regardsMatthias
推荐答案
我明白了.因为Apache 2.4.7不支持套接字文件,所以我不得不使用ProxyPassMatch
I got it. Because Apache 2.4.7 does not support socket file, I had to use ProxyPassMatch
这篇关于Sethandler fcgi代理在Ubuntu 14.04/Apache 2.4.7 php7.2-fpm上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!