windows 当 DocumentRoot 指向两个不同的驱动器时,Apache 给了我 403 Access Forbidden
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/89118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives
提问by RobbieGee
I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file:
尝试在文档根目录所在的驱动器与 apache 所在的驱动器不同的虚拟主机下打开页面时,我收到 403 访问被禁止。我使用 apachefriends 版本安装。这是我的 httpd-vhosts.conf 文件:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName foo.localhost
DocumentRoot "C:/xampp/htdocs/foo/public"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName bar.localhost
DocumentRoot "F:/bar/public"
</VirtualHost>
When opening bar.localhost in my browser, Apache is giving me 403 Access Forbidden. I tried setting lots of different access rights, even full rights to everyone, but nothing I tried helped.
在浏览器中打开 bar.localhost 时,Apache 给了我 403 Access Forbidden。我尝试设置许多不同的访问权限,甚至为每个人设置完全权限,但我尝试过的一切都没有帮助。
Edit: Thanks! For future reference, add 'Options indexes' within to show directory indexes.
编辑:谢谢!为了将来参考,在其中添加“选项索引”以显示目录索引。
回答by Michael Klink
You did not need
你不需要
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
the only thing what you need is...
你唯一需要的是......
Require all granted
...inside the directory section.
...在目录部分内。
See Apache 2.4 upgrading side:
参见 Apache 2.4 升级端:
回答by Mark Embling
回答by cloudwhale
For Apache 2.4.2: I was getting 403: Forbiddencontinuously when I was trying to access WAMP on my Windows 7 desktop from my iPhone on WiFi. On one blog, I found the solution - add Require all grantedafter Allow allin the <Directory>section. So this is how my <Directory>section looks like inside <VirtualHost>
对于Apache 2.4.2:当我尝试通过 WiFi 从 iPhone 访问 Windows 7 桌面上的 WAMP 时,我一直收到403: Forbidden。在一个博客上,我找到了解决方案 -在<Directory>部分中的Allow all之后添加Require all grant。所以这就是我的<Directory>部分在 <VirtualHost> 中的样子
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
回答by mujaffars
I have fixed it with removing below code from
我已经通过删除以下代码来修复它
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conffile
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf文件
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
And added
并补充说
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
And it has worked like charm
它的作用就像魅力一样
回答by Dupls
Solved 403: Forbidden when visiting localhost. Using ports 80,443,3308 (the later to handle conflict with MySQL Server installation) Windows 10, XAMPP 7.4.1, Apache 2.4.x My web files are in a separate folder.
解决了403:访问本地主机时禁止。使用端口 80,443,3308(后者处理与 MySQL 服务器安装的冲突) Windows 10、XAMPP 7.4.1、Apache 2.4.x 我的 Web 文件位于单独的文件夹中。
httpd.conf - look for these lines and set it up where you have your files, mine is web folder.
httpd.conf - 查找这些行并将其设置在您拥有文件的位置,我的是 web 文件夹。
DocumentRoot "C:/web"
<Directory "C:/web">
Changed these 2 lines.
改变了这2行。
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
to this
对此
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Require all granted
</Directory>
</VirtualHost>
Add your details in your hosts file C:\Windows\System32\drivers\etc\hosts file
在您的主机文件 C:\Windows\System32\drivers\etc\hosts 文件中添加您的详细信息
127.0.0.1 localhost
127.0.0.1 project1.localhost
Stop start XAMPP, and click Apache admin (or localhost) and the wonderful XAMPP dashboard now displays! And visit your project at project1.localhost
停止启动 XAMPP,然后单击 Apache admin(或 localhost),现在显示精彩的 XAMPP 仪表板!并在 project1.localhost 访问您的项目