我发布这个是因为我最近在设置一个带有MAMP堆栈的虚拟主机时遇到了很多麻烦,因为苹果在Mac OS 10.8的默认Apache2安装上限制了可用的PHP版本。
这是一个关于如何做的非常快速的指南,我欠这个问题的解决方案堆栈溢出:
你可以把这看作是对我有用的东西的汇编,因为被接受的答案没有效果,而是那些分数明显较低的答案。
类似地,我所看到的每一个指南都没有提到用户对源问题回答的一些要点。
确保指定要侦听的端口,对于我,我指定了8080
。这将是本系列说明的情况。
Listen 8080
-默认值为80
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
您真的应该在您的Web服务器、Apache或Nginx(或您使用的任何其他服务器)上为子域添加一个句柄。将www路由到非www的东西。
httpd。conf
文件位于Apache2的子目录中。通常在/conf
<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上的“所有人”提供“只读”访问权限,例如“文档”或“电影”等李>
尽管上面的答案很有解释性,但在将虚拟主机迁移到Apache2.4时,以下两件事是最重要的
>
转到wamp/bin/apache/apache2.4. x/conf/httpd.conf查找#包含conf/额外/httpd-vhosts.conf
并取消注释到包含conf/额外/httpd-vhosts.conf
在wamp/bin/apache/apache2中添加虚拟主机。4.x/conf/extra/httpd-vhosts。形态
as
<VirtualHost *:80>
ServerAdmin admin@localhost.com
DocumentRoot "H:/Wamp/www/mysite"
ServerName mysite
ServerAlias mysite
<Directory />
Require all granted
</Directory>
</VirtualHost>
注意: