我对自己遇到的问题感到困惑,非常感谢您解决该问题。
我有一台运行Mac OS X Mavericks 10.9.2的iMac
我已经设置了我的apache服务来从服务器根目录/ Volume / sites /
我使用的是动态虚拟主机,因此只需添加带有* .dev后缀的目录,它便会成为虚拟主机。
我的主机文件非常基本:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
我的httpd-vhosts.conf文件如下:
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
#allow access to the Hosts directory where your sites are
<Directory "/Volumes/sites">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
#you could configure the following to only allow access from localhost
Order allow,deny
Allow from all
</Directory>
#get the server name from the Host: header
UseCanonicalName Off
VirtualDocumentRoot /Volumes/sites/%0/
这一切都奏效。而且我还没有更改httpd.conf文件中的任何内容。
但是我无法加载本地主机
我也无法加载127.0.0.1
我运行命令sudo lsof -i :80 | egrep "PID|LISTEN"
以查看是否有任何PID在端口80上监听。结果为空。
我尝试重新启动apache并也停止然后使用以下命令启动apache
sudo apachectl stop
sudo apachectl start
sudo apachectl restart
没用。
我通过发出命令来检查apache是否正在运行 httpd -v
回报是:
Server version: Apache/2.2.26 (Unix)
Server built: Dec 10 2013 22:09:38
我尝试通过命令行连接到localhost和127.0.0.1,结果如下:
alisamii at alisamii in ~
$ telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
telnet: Unable to connect to remote host
alisamii at alisamii in ~
$ telnet 127.0.0.1 80
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
alisamii at alisamii in ~
$ lynx http://localhost
Looking up localhost
Making HTTP connection to localhost
Alert!: Unable to connect to remote host.
lynx: Can't access startfile http://localhost/
alisamii at alisamii in ~
$ lynx http://127.0.0.1
Looking up 127.0.0.1
Making HTTP connection to 127.0.0.1
Alert!: Unable to connect to remote host.
lynx: Can't access startfile http://127.0.0.1/
alisamii at alisamii in ~
请帮忙。