【问题标题】:You don't have permission to access / on this server WAMP server on Windows 7 after setting up vhost设置 vhost 后,您无权访问 Windows 7 上此服务器 WAMP 服务器上的 /
【发布时间】:2015-02-11 16:25:28
【问题描述】:

我收到此错误:您无权访问此服务器上的 /。

在 apache 网络服务器和 vhost 中启用了 vhost 插件,我有这个:

<VirtualHost *:80>
    DocumentRoot "C:/wamp/www/myfiles"
    ServerName domain.com
    ServerAlias domain.com
    ErrorLog "logs/domain.com.log"
    CustomLog "logs/domain.com" common
 </VirtualHost>

在我的笔记本电脑上工作,而不是在运行 windows7 的 tmp-server 上

【问题讨论】:

    标签: apache wamp vhosts


    【解决方案1】:

    首先,当您设置虚拟主机时,最好也为 localhost 创建一个。

    您还需要告诉 apache 允许从哪个 IP 地址接受每个虚拟主机的连接。

    那就试试这个

    # Should be the first VHOST definition so that it is the default virtual host
    # Also access rights should remain restricted to the local PC and the local network
    # So that any random ip address attack will recieve an error code and not gain access
    <VirtualHost *:80>
        ServerAdmin webmaster@homemail.net
        DocumentRoot "c:/wamp/www"
        ServerName localhost
        ServerAlias localhost
        <Directory  "c:/wamp/www">
            AllowOverride All
            <IfDefine APACHE24>
                Require local
            </IfDefine>
            <IfDefine !APACHE24>
                Order Deny,Allow
                Deny from all
                Allow from 127.0.0.0 localhost ::1
            </IfDefine>
        </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot "C:/wamp/www/myfiles"
        ServerName domain.com
        ServerAlias domain.com
        ErrorLog "logs/domain.com.log"
        CustomLog "logs/domain.com" common
        <Directory  "C:/wamp/www/myfiles">
            AllowOverride All
            Options Indexes FollowSymLinks
            <IfDefine APACHE24>
                Require local
                Require ip 192.168.2
            </IfDefine>
    
            <IfDefine !APACHE24>
                Order Deny,Allow
                Deny from all
                Allow from 127.0.0.0 localhost ::1
            </IfDefine>
    </VirtualHost>
    

    最后,如果您的意思是您在 Apache 中启用了 vhost_alias_module,那么您不需要它来使用这样的虚拟主机,所以您应该禁用它。

    要激活extra\vhost-httpd.conf 更改,不要忘记取消注释httpd.conf 文件中的这一行,以便包含这个额外的文件。

    Include conf/extra/httpd-vhosts.conf
    

    【讨论】:

    • 我正在使用 vhost_alias_module,所以我可以在该文件中包含我所有的虚拟主机(附加/虚拟主机),所以我想肯定有一些更新
    • 禁用虚拟主机并将其直接添加到 http.conf 文件中!所以我想它没问题,但我无法让 extras/vhost-conf 工作。
    • 查看我更改后的答案。
    • 我试过这个,然后把 conf 移到那个位置,没有运气,一定是我的服务器不允许我使用虚拟主机。尽管您的示例在不使用 vhost 文件的情况下运行良好!谢谢!
    猜你喜欢
    • 2015-12-24
    • 2016-09-11
    • 1970-01-01
    • 2012-05-22
    • 2013-06-30
    • 2019-02-22
    相关资源
    最近更新 更多