OSX Mavericks - 使用子域设置Apache

时间:2013-11-26 08:47:08

标签: php macos apache subdomain

我已经在Mac上成功设置了运行PHP的本地服务器,但是我无法将额外的本地站点设置为子域(即site2.localhost)

这是我到目前为止所拥有的:

主持文件:

##
# 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
127.0.0.1       site2.localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

的httpd-vhosts.conf:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/Users/user/Sites/site2"
    ServerName site2.localhost
</VirtualHost>

我在httpd.conf文件中取消注释了以下行:

Include /private/etc/apache2/extra/httpd-vhosts.conf

我不确定我还需要添加什么,或者我需要添加它。

1 个答案:

答案 0 :(得分:2)

好吧,看起来好像我需要看起来更难......实际上它设置正确,但出于某种原因,当我在浏览器中键入site2.localhost时,它默认为https。

通过手动输入http://site2.localhost,它可以正常工作。