问题
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
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>
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.
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 regards Matthias
回答1:
I got it. Because Apache 2.4.7 does not support socket file, I had to use ProxyPassMatch
来源:https://stackoverflow.com/questions/55395752/sethandler-fcgi-proxy-not-working-on-ubuntu-14-04-apache-2-4-7-php7-2-fpm