无法在 OS X 上设置虚拟主机

无法在 OS X 上设置虚拟主机

我正在尝试为 PHP 开发创建一个虚拟主机,因此我不去http://localhost/new_website,而是去new_website.dev并获取网站。

我已经在 /Sites 文件夹中创建了目录并编辑了/etc/apache2/extra/httpd-vhosts.conf文件和/private/etc/hosts文件。

我的 vhosts 文件的内容:

#
# 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.
#

<VirtualHost *:80>
    DocumentRoot "/Users/Rob/Sites"
    ServerName localhost
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "/Users/Rob/Sites/new_website"
    ServerName new_website.dev
</VirtualHost>

我的 hosts 文件的内容如下:

##
# 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

127.0.0.1 new_website.dev

从我在互联网上找到的信息来看,这应该是个窍门,但不知何故,我没有从目录中获取 index.php new_website,但我从目录中获取了 index.php Sites。所以可以说是服务器的根目录。我做错了什么?

相关内容