Apache 与本地主机的连接失败

Apache 与本地主机的连接失败,apache,localhost,vhosts,Apache,Localhost,Vhosts,我设置/etc/apache2/extra/httpd-vhosts.conf如下: # Ensure that Apache listens on port 80 Listen 80 # Listen for virtual host requests on all IP addresses NameVirtualHost *:80 <VirtualHost *:80> ServerName localhost DocumentRoot /Lib

我设置/etc/apache2/extra/httpd-vhosts.conf如下:

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
        ServerName localhost
        DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
#确保Apache侦听端口80
听80
#侦听所有IP地址上的虚拟主机请求
名称虚拟主机*:80
服务器名本地主机
DocumentRoot/Library/WebServer/Documents/
In/Library/WebServer/Documents/是标准的index.html.en文件,在我将httpd-vhosts.conf包含到httpd.conf中之前,它在浏览器中显示得非常完美


使用Chrome和Firefox与localhost的连接都失败。设置是否正确?还有什么问题吗?

我解决了这个问题。我无法陈述进一步的信息,因为我不知道在哪里可以找到问题。这篇文章给了我正确的方向:


在httpd.conf文件中给了我一个语法错误。修好后一切都好了。重要的是有机会运行configtest。

apache启动了吗因为在我看来,无法连接在配置错误时失败。apachectl start让我org.apache.httpd:已加载。所以我想它开始了。我也重新启动了好几次。如果我不包括httpd-vhosts.conf,那么一切都像一个符咒。我还能找什么?
sudo apachectl configtest