
No estoy seguro de si se trata de un problema de configuración de php, apache o iptables, pero recibo el siguiente error al intentar acceder a un .php
archivo. Avíseme si necesita más información para ayudarme a diagnosticar. No sé qué comprobar a continuación. Gracias.
error.log
:
[Thu May 08 16:43:15.392784 2014] [proxy:error] [pid 23112] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9000 (*) failed
[Thu May 08 16:43:15.392891 2014] [proxy_fcgi:error] [pid 23112] [client 74.164.254.206:52788] AH01079: failed to make connection to backend: 127.0.0.1
Seguíesta guíay un PHP 5.5.9 y Apache 2.4.7 en ejecución
Tengo los módulos mod_proxy
y mod_proxy_so
cargados:
# grep LoadModule /etc/apache2/apache2.conf
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/lib/apache2/modules/mod_proxy_fcgi.so
Aquí está la directiva ProxyPassMatch:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1
También intenté usar UDS con la siguiente directiva, pero la prueba de configuración de Apache se queja de una URL absoluta:
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1:80/path/to/root/
Aquí estáiptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port- unreachable
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:finger
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:urd
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3s
ACCEPT tcp -- anywhere anywhere tcp dpt:imap2
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
ACCEPT tcp -- anywhere anywhere tcp dpt:submission
ACCEPT tcp -- anywhere anywhere tcp dpt:webmin
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT icmp -- anywhere anywhere
LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix "iptables denied: "
DROP all -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DROP all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Respuesta1
Compruebe si PHP-FPM
está funcionando. El registro de errores dice que apache
no se puede establecer conexión con 127.0.0.1:9000. Hágalo funcionar y (tal vez) desaparecerá el error.
También verifique si PHP-FPM
se ejecuta a través de un socket. Tal vez se esté ejecutando pero no escuchando en la pila TCP/IP.
Respuesta2
Según el comentario de Chris, solo quería agregar si apache/php admite conexiones de socket (parece que si apache > 2.4.10, puede admitirlo), también puede cambiarlo para usarlo en su configuración de apache. Revisé el archivo php vi /etc/php/7.0/fpm/pool.d/www.conf para ver qué socket escucha en la línea de escucha:
listen = /run/php/php7.0-fpm.sock
Luego lo agregué a mi archivo /etc/apache2/sites-enabled/000-default.conf (o cualquier sitio web en el que desee habilitar)...
<FilesMatch \.php$>
# 2.4.10+ can proxy to unix socket
# SetHandler "proxy:unix:/var/run/php?-fpm.sock|fcgi://localhost/"
# Else we can just use a tcp socket:
# SetHandler "proxy:fcgi://127.0.0.1:9000"
SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost/"
</FilesMatch>
Luego reinicie el servidor web y luego aparece index.php:
sudo service apache2 restart