我很难让多个站点使用虚拟主机与 MAMP 一起工作。 以下是我在MBA上设置的内容。 如果我打开我的网络浏览器并转到"http:local.login.dev"或"http://dev.login.localhost"(重新配置后),我会得到保存在/Users/aaron/localhost 中的索引页。 我的虚拟主机部分中列出的第一项 不是保存在我要访问的虚拟主机中的索引页。 我设置的其他网站给了我相同的结果。 "http:next.site.localhost" = 在/Users/aaron/localhost 中显示索引页。
有人有什么想法吗? 我的最终目标是将 MAMP 虚拟主机配置为使用 SSL 工作和测试。
最重要的是,似乎只读取了第一个虚拟主机条目,这就是列出的每个主机所使用的条目。 我是否在某处错过了一些设置?
环境: - MBA with OS X, Yosemite
-
MAMP 3.0.7.3 分别使用 http 和 mysql 的端口 80 和 3306
-
httpd.conf 文件: Include/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
127.0.0.1 本地主机
127.0.0.1 local.login.dev<VirtualHost *> DocumentRoot "/Users/aaron/localhost" ServerName localhost </VirtualHost> <VirtualHost *:80> — I tried both with and without :80 DocumentRoot "/Users/aaron/localhost/training/login/public" ServerName local.login.dev </VirtualHost>
还尝试以这种方式配置我的主机和httpd-vhosts.conf - 来自另一篇文章:
127.0.0.1 本地主机
127.0.0.1 dev.login.localhost
<VirtualHost *>
DocumentRoot "/Users/aaron/localhost"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName dev.login.localhost
ServerAlias dev.login.localhost
<Directory "/Users/aaron/localhost/training/login/public">
Allow from All
AllowOverride all
Options -Indexes +FollowSymlinks
</Directory>
</VirtualHost>
只是玩得更多,我在我的httpd-vhosts.conf文件中注释掉了第一个"本地主机",看起来我现在可以正确导航到我的本地站点。 以下是我目前配置的内容。
httpd-vhosts.conf:
# <VirtualHost *>
# DocumentRoot "/Users/aaron/localhost/"
# ServerName localhost
# </VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName dev.login.localhost
ServerAlias dev.login.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/site1"
ServerName dev.site1.localhost
ServerAlias dev.site1.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/site2"
ServerName dev.site2.localhost
ServerAlias dev.site2.localhost
</VirtualHost>
主机文件:
127.0.0.1 localhost
######Locahost Dev Sites
127.0.0.1 dev.login.localhost dev.site1.localhost dev.site2.localhost
现在看看我是否可以让 SSL 工作。
如果其中有任何不正确之处,请告诉我... 但是此配置是我可以使用端口 80 使虚拟主机工作的唯一方法,截至目前... 如果我在与 443 混合时遇到问题,我会更新