Usando ProxyPassMatch para FastCGI, resulta em conexão recusada na porta 9000

Usando ProxyPassMatch para FastCGI, resulta em conexão recusada na porta 9000

Não tenho certeza se este é um problema de configuração do php, apache ou iptables, mas recebo o seguinte erro ao tentar acessar um .phparquivo. Por favor, deixe-me saber se precisar de mais informações para me ajudar a diagnosticar. Não sei o que verificar a seguir. Obrigado.

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

eu seguieste guiae um PHP 5.5.9 e Apache 2.4.7 em execução

Eu tenho os módulos mod_proxye mod_proxy_socarregados:

# 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 

Aqui está a diretiva ProxyPassMatch:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1

Também tentei usar o UDS com a seguinte diretiva, mas o teste de configuração do Apache reclama de um URL absoluto:

ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1:80/path/to/root/

Aqui 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

Responder1

Verifique se PHP-FPMestá em execução. O log de erros diz que apachenão é possível fazer conexão com 127.0.0.1:9000. Faça-o funcionar e (talvez) o erro desaparecerá.

Verifique também se PHP-FPMestá executando via soquete. Talvez esteja em execução, mas não esteja escutando na pilha TCP/IP.

Responder2

De acordo com o comentário de Chris, eu só queria acrescentar se o apache/php suporta conexões de soquete (parece que se o apache> 2.4.10 pode suportá-lo), você também pode alterar para usar isso na configuração do apache. Eu verifiquei o arquivo php vi /etc/php/7.0/fpm/pool.d/www.conf para ver qual soquete está ouvindo na linha de escuta:

listen = /run/php/php7.0-fpm.sock

Em seguida, adicionei isso ao meu arquivo /etc/apache2/sites-enabled/000-default.conf (ou qualquer site que você deseja ativar) ...

<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>

Em seguida, reinicie o servidor web e então index.php aparece para mim:

sudo service apache2 restart

informação relacionada