我完全搞错了阿帕奇听的东西。 我现在的问题是。 当我让它听
NameVirtualHost *:80 Listen 127.0.0.1:80 Listen 192.168.1.23:80
它可以通过networking访问吗? 因为我的互联网连接到192.168.1.23:80
用netstat检查Apache正在侦听端口80。
% sudo netstat -apn|grep :80 tcp 0 0 :::80 :::* LISTEN 1318/httpd
另外请确保您没有任何阻止此访问的防火墙规则,具体而言,您应该在http的INPUT链上具有ACCEPT规则。
% sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination
您可以暂时禁用防火墙来确认:
% /etc/init.d/iptables stop
那么防火墙看起来像这样:
% sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
我也会检查出Apache的错误和访问日志文件,大多数linux将它们存放在/var/log ,可能是/var/log/httpd 。 他们通常是2个文件, error_log和access_log 。
关于你在启动时出现的错误,听起来像你需要在你的httpd.conf文件中设置ServerNamevariables。
ServerName localhost
这似乎是Ubuntu上的apache2的问题。 我发现其他网站上的解决scheme是将ServerName设置为本地主机的几个线程。