Apache 阻止在用户空间内使用 VirtualHost? Mac OS X
我正在尝试为我正在进行的一些网络项目设置一个虚拟主机。为此,我在我的用户帐户 ~/Projects/ 中有一个文件夹,其中放置了所有项目,并且我希望保持这种状态。当我尝试在 ~/Projects/aproject/web 下创建 VirtualHost 时,Apache 拒绝我访问。
经过一番尝试,我发现如果我将项目放在用户空间 (~/....) 之外的其他目录下,Apache 会让我创建 VirtualHost,否则将拒绝访问。
我认为这个问题与 UserDir
指令有关,我认为该指令阻止访问用户空间中的每个文件夹,但 UserDir
中列出的文件夹 - 在我的情况下它是 < code>UserDir Sites - 但我不知道如何规避此问题并允许 Apache 提供自定义用户空间文件夹。有什么想法吗?
我正在尝试的 httpd.conf 中的指令是这样的:
<VirtualHost *:80>
DocumentRoot "/Users/myuser/Projects/myproject/web"
ServerName www.myproject.local
</VirtualHost>
<Directory "/Users/myuser/Projects/myproject/web">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
我还在 httpd.conf 中设置了指令 NameVirtualHost *:80
。 并在 /etc/hosts 中创建适当的指令:127.0.0.1 www.myproject.local
。
此致。
I am trying to set up a VirtualHost for some web projects I have undergoing. To do this, I have a folder in my User account ~/Projects/ in which I place all of my projects and I want to remain like that. When I tried to create a VirtualHost under ~/Projects/aproject/web Apache denies me access.
After some tries, I discovered that if I put the project under other directory than the user space (~/....) the Apache lets me create the VirtualHost that otherwise denies access.
I think this problem has to do with the UserDir
directive which I think prevents access to every folder in user space but the ones listed in the UserDir
- in my case it is UserDir Sites
- but I do not know how to circumvent this and allow Apache to serve custom user space folders. Any ideas?
The directives in httpd.conf that I am trying are this ones:
<VirtualHost *:80>
DocumentRoot "/Users/myuser/Projects/myproject/web"
ServerName www.myproject.local
</VirtualHost>
<Directory "/Users/myuser/Projects/myproject/web">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I also have set the directive NameVirtualHost *:80
in httpd.conf.
And created the appropriate directive in /etc/hosts: 127.0.0.1 www.myproject.local
.
Best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要更改用户的配置:
users/{username).conf
然后将所有
AuthConfig
更改为AllowOverride
You may need to alter the config for your user:
users/{username).conf
Then all
AuthConfig
toAllowOverride