我正在尝试为位于我的MAMP htdocs文件夹中的特定项目添加vhost。
我做的步骤:
打开/Applications/MAMP/htdocs/conf/apache/httpd.conf
并取消注释Include /Applications/MAMP/htdocs/conf/apache/extra/httpd-vhosts.conf
行。
打开/Applications/MAMP/htdocs/conf/apache/extra/httpd-vhosts.conf
并删除两个演示虚拟主机,并添加以下内容:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/arko/Sites/mysite"
ServerName mysite
</VirtualHost>
编辑主机文件:sudo vim /etc/hosts
并添加以下行:
127.0.0.1 mysite
我的主机文件现在看起来像这样:
##
# 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
# MAMP Virtual Hosts
127.0.0.1 mysite
然后我打开了我的MAMP并重新启动了服务器(停止服务器,然后启动服务器)。
每当我转到http://mysite/
时,我只会得到/Applications/MAMP/htdocs
的内容(我的所有文件夹中都有一个丑陋的列表,因为我的htdocs
文件夹中没有索引文件。< / p>
所以它似乎忽略了我的vhost,只是使用我的hosts文件将http://mysite/
路由到127.0.0.1
(localhost)
当我转到http://mysite/时,我在apache错误日志中收到此错误:
[Wed Mar 16 11:04:39 2016] [error] [client 127.0.0.1] client denied by server configuration: /Applications/MAMP/htdocs/.DS_Store