我发布这个是因为我最近在设置带有MAMP堆栈的虚拟主机时遇到了很多麻烦,因为Apple在Mac OS 10.8的默认Apache2安装上限制了可用的PHP版本。
这是一个关于如何做的非常快速的指南,我欠Stack Overflow上这个问题的解决方案:
您可以将此视为对我有用的汇编,因为已接受的答案没有效果,而是那些得分明显较低的答案。
同样,我所看到的每一个指南都没有提到用户在来源问题上回答的一些要点。
答案 0 :(得分:19)
确保您指定要收听的端口,对我来说,我指定了8080
。这一系列说明就属于这种情况。
Listen 8080
- 默认为80
/etc/hosts
文件以欺骗您的环回地址,127.0.0.1 127.0.0.1 localhost
127.0.0.1 some.example # domain-name.domain-TLD
127.0.0.1 www.some.example # The same as the above line, but with www. prefixed
你应该在你的网络服务器,Apache或Nginx(或者你使用的其他任何东西)上添加子域的句柄。将www路由到非www。
httpd.conf
文件。 通常在/conf
Include conf/extra/httpd-vhosts.conf
LoadModule log_config_module modules/mod_log_config.so
httpd-vhosts.conf
,您可以注释掉文件中的两个示例虚拟主机。 通常在/conf/extra
<VirtualHost *:80> # Change the 80 to the number Apache2 "Listen"s on. In my case, 8080 ServerName SERVER-ADDRESS # E.g. mywebsite.local ServerAlias WWW.SERVER-ADDRESS # E.g. www.mywebsite.local DocumentRoot " SERVER-FILE-ROOT " # E.g. "Users/user-name/Sites" <Directory /> # This should be a full path, though Require all granted # Required for permission errors Options Indexes FollowSymLinks Includes ExecCGI AllowOverride none </Directory> </VirtualHost>
根据自己的喜好编辑虚拟主机后,您就完成了,重新启动Apache并享受。
本指南已包含已实施的修补程序,但如果您仍然遇到权限错误:
DocumentRoot
不在您的用户明确拥有的任何文件中。如果需要,请在Mac上为该特定文件夹提供"Read Only"
访问“Everyone”的权限,例如。 “文件”或“电影”等.... 答案 1 :(得分:1)
虽然上面的答案很明确,但在将虚拟主机迁移到apache 2.4时,以下两件事情是最重要的
转到wamp/bin/apache/apache2.4.x/conf/httpd.conf
查找#Include conf/extra/httpd-vhosts.conf
并取消注释到Include conf/extra/httpd-vhosts.conf
将wamp/bin/apache/apache2.4.x/conf/extra/httpd-vhosts.conf
中的虚拟主机添加为
<VirtualHost *:80>
ServerAdmin admin@localhost.com
DocumentRoot "H:/Wamp/www/mysite"
ServerName mysite
ServerAlias mysite
<Directory />
Require all granted
</Directory>
</VirtualHost>
注意:<Directory **/**>
/是重要的