我不确定如果这是一个PHP,Apache或iptablesconfiguration问题,但是当我试图访问.php
文件时收到以下错误。 请让我知道,如果你需要更多的信息来帮助我诊断,我不知道接下来要检查什么。 谢谢。
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
我遵循这个指南 ,运行PHP 5.5.9和Apache 2.4.7
我有加载mod_proxy
和mod_proxy_so
模块:
# 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
这是ProxyPassMatch指令:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1
我也尝试使用以下指令的UDS,但Apacheconfigurationtesting抱怨绝对的url:
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1:80/path/to/root/
这里是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
检查PHP-FPM
是否正在运行。 错误日志说, apache
不能连接到127.0.0.1:9000。 让它运行,(可能)错误将会消失。
另外检查PHP-FPM
是否通过套接字运行。 也许它正在运行,但不能在TCP / IP堆栈中侦听。
Per Chris的评论,我只是想添加,如果Apache / PHP不支持套接字连接(看起来像如果Apache> 2.4.10,它可以支持它),你也可以改变使用你的Apacheconfiguration。 我检查了php vi /etc/php/7.0/fpm/pool.d/www.conf文件,以查看在listen行中侦听的套接字:
listen = /run/php/php7.0-fpm.sock
然后添加到我的/etc/apache2/sites-enabled/000-default.conf文件(或任何网站,你想启用)…
<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>
然后重新启动Web服务器,然后index.php为我显示:
sudo service apache2 restart