如何使apache2听localhost和局域网的电脑

我完全搞错了阿帕奇听的东西。 我现在的问题是。 当我让它听

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 

另外请确保您没有任何阻止此访问的防火墙规则,具体而言,您应该在httpINPUT链上具有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_logaccess_log

关于你在启动时出现的错误,听起来像你需要在你的httpd.conf文件中设置ServerNamevariables。

 ServerName localhost 

这似乎是Ubuntu上的apache2的问题。 我发现其他网站上的解决scheme是将ServerName设置为本地主机的几个线程。

  • 如何解决Apache – “无法可靠地确定服务器的完全合格的域名,使用127.0.1.1的ServerName”错误在Ubuntu上
  • Apache2的错误?
  • [解决] apache2:无法可靠地确定服务器的完全合格的域名,使用Xubuntu上的ServerName 127.0.1.1
  • [求助]“无法可靠地确定服务器的完全合格的域名,使用… for ServerName”