0

I'm configuring PHP_FPM on a Centos 6 distribution. I'm using php 5.4.45 and apache 2.2.15 and the "mod_proxy.so" to call the socket. But with the following Vhost and php-fpm configuration I still get the same two issues in my site logs :

[Tue Mar 10 11:36:49 2020] [error] (111)Connection refused: proxy: FCGI: attempt to connect to 127.0.0.1:0 (*) failed
[Tue Mar 10 11:36:49 2020] [error] [client 192.168.1.38] AH01079: failed to make connection to backend: localhost

I'have tried and read a huge amount of solutions but no one of them helped me so much. Here the configuration of my Vhost and php-fpm www.conf file :

<VirtualHost _default_:80>
   DocumentRoot "/var/www/html"

   <Directory "/var/www/html">
           Order allow,deny
            Allow from all
           AllowOverride All
   </Directory>

   ErrorLog logs/default-error_log
   LogLevel warn
   TransferLog logs/default-access_log
   CustomLog logs/default-request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

    ProxyPassMatch ^/(.*\.php)$ fcgi://localhost/var/www/html/$1
    DirectoryIndex index.php info.php

    <FilesMatch \.php$>
           SetHandler "proxy:unix:/var/run/php-fpm/default.sock|fcgi://localhost/"
    </FilesMatch>

listen = /var/run/php-fpm/default.sock
listen.owner = apache
listen.group = apache
listen.mode = 0660
user = apache
group = apache
listen.allowed_clients = 127.0.0.1
php_value[opcache.file_cache] = /var/lib/php/opcache

Thank you for you attention. Best regards

Suffren
  • 5
  • 2

1 Answers1

0

Apache 2.2 natively does not have mod_proxy_fcgi (cf. this question), you must have obtained it from alternative sources. Moreover using mod_proxy with the SetHandler directive works from version 2.4.10. Therefore:

  1. Your <FilesMatch> block has no effect, so you can delete it,
  2. Only your ProxyPassMatch directive is working. However your version of mod_proxy_fcgi does not support Unix Domain Sockets, so you need to connect to PHP-FPM using a TCP/IP socket. In order to do so, modify the www.conf file and replace the listen directive with:

    listen 127.0.0.1:9000
    

    and restart PHP-FPM. On Apache 2 side replace the ProxyPassMatch directive with:

    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
    

    and reload Apache2.

Piotr P. Karwasz
  • 5,292
  • 2
  • 9
  • 20