apache php Virtualhost


apache php Virtualhost

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

我为此使用了以下代码。

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 内容.预订

但是我收到以下错误:

---------------------------------------------------------
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
---------------------------------------------------------

任何人都可以解决此问题吗?

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

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

接下来,使用一些Directory选项更新您的虚拟主机文件。

<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/"

希望这有帮助。

您的服务器名称带有一个"o",您的主机文件条目带有"oo"(两个)。

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

如果您不包含索引。html|htm|php] 在目录中,默认操作可能是列出该目录中的所有文件,或者更常见的是出于安全考虑,抛出此错误。

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

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

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