1

我正在尝试在我的系统中实现虚拟主机。

我为此使用了以下代码。

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Users/shanker/Documents/content_booking/"  
    ServerName content.boking
    Alias /booking "/Users/shanker/Documents/content_booking/public/"
</VirtualHost>

我也将主机文件更新为

127.0.0.1 content.booking

但我收到以下错误:

---------------------------------------------------------
Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.
Error 403
---------------------------------------------------------

任何人都可以解决这个问题。

4

4 回答 4

2

首先在 Apache 中检查您的 httpd.conf 文件并确保虚拟主机已打开。(删除“#”以打开/取消注释)。

 #Virtual hosts
 Include conf/extra/httpd-vhosts.conf

接下来使用一些Directory选项更新您的 vhosts 文件。

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Users/shanker/Documents/content_booking/"  
ServerName content.boking
<Directory "C:/Users/shanker/Documents/content_booking/">
  Options Indexes FollowSymLinks ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
Alias /booking "/Users/shanker/Documents/content_booking/public/"

希望这可以帮助。

于 2012-11-07T22:12:11.880 回答
1

您的 ServerName 带有一个“o”,您的主机文件条目带有“oo”(两个)。

一旦你修复了那个错字,它会起作用吗?

于 2012-04-13T18:59:09.063 回答
1

如果您没有在目录中包含 index.[html|htm|php],则默认操作可能是列出该目录中的所有文件或更常见的安全性,以引发此错误。

http://127.0.0.1/导致 Apache 查找 index.[html|htm|php] 文件,如果没有,并且您的安全性不允许列出目录(它不应该列出),则此是错误。

在正确的目录中创建一个 index.html 文件,看看是否有帮助。

于 2012-04-13T19:05:37.327 回答
0

OS X 的权限等已设置(开箱即用)以提供 Web 文档,/Users/shanker/Sites因此,如果这是与权限相关的问题,您可以尝试将代码移至/Users/shanker/Sites/content_booking/目录并更新DocumentRoot指令以避开任何权限问题.

于 2012-04-13T19:03:25.783 回答