2014-12-01 193 views
1

我在這裏看過很多例子,但我仍然無法從我的其他計算機訪問我的WAMP服務器。我從WAMP安裝的計算機沒有問題。禁止:您沒有權限訪問/

我注意到它說You don't have permission to access / - 爲什麼/

// httpd.conf中

<Directory "D:/wamp/www/"> 
    Options Indexes FollowSymLinks 
    AllowOverride all 
    Order Deny,Allow 
    Deny from all 
    Allow from ::1 
    Allow from 192.168.0.1 // <- typo 
    Allow from 192.168.1.148 
</Directory> 

//httpd.vhosts.conf

<VirtualHost 192.168.1.119> 
    DocumentRoot D:/wamp/www/mysite/ 
    ServerName mysite.com 
    ServerAlias mysite.com 
</VirtualHost> 

//主機文件

192.168.1.119 localhost 
192.168.1.119 mysite.com 
+0

什麼版本WAMPServer您使用的是? – RiggsFolly 2014-12-01 23:06:50

+0

我正在使用版本2.5 – Steven 2014-12-02 07:30:40

回答

1

嘗試這些變化

一本控制對您的WAMPS的訪問erver主頁,將所有可能的本地地址添加到允許列表中。

您似乎在列表中有2個子網,是一個錯字?我假設如此。

此外,如果您只使用IP地址的前三個四分位數,它將允許從該子網上的任何IP。

// httpd.conf中

<Directory "D:/wamp/www/"> 
    Options Indexes FollowSymLinks 
    AllowOverride all 
    Order Deny,Allow 
    Deny from all 
    Allow from ::1 127.0.0.1 localhost 
    Allow from 192.168.1 
</Directory> 

你不提你的VHOST定義的任何端口號,也沒有必要使用一個特定的IP地址。

此外,最好添加一個本地主機VHOST,並將訪問限制即<Directory...>塊放在每個單獨的VHOST定義中。然後,您可以專門修改每個VHOST上的訪問權限。

此外,Apache 2.4.x中訪問權限chnaged的語法,所以我使用在WAMPServer2.5版本中添加的參數對訪問權限部分進行了編碼,但它應該可以正常工作,即使您仍在使用一箇舊版本WAMPServer 2.4,即或2.2

//演員/的httpd-vhost.conf

# 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> 
    DocumentRoot "D:/wamp/www" 
    ServerName localhost 
    ServerAlias localhost 
    <Directory "D:/wamp/www"> 
     AllowOverride All 
     <IfDefine APACHE24> 
      Require local 
      Require ip 192.168.1 
     </IfDefine> 
     <IfDefine !APACHE24> 
      Order Deny,Allow 
      Deny from all 
      Allow from 127.0.0.0/8 localhost ::1 192.168.1 
     </IfDefine> 
    </Directory> 
</VirtualHost> 



<VirtualHost *:80> 
    DocumentRoot "D:/wamp/www/mysite" 
    ServerName mysite.com 
    ServerAlias www.mysite.com 
    <Directory "D:/wamp/www"> 
     AllowOverride All 
     <IfDefine APACHE24> 
      Require local 
      Require ip 192.168.1 
     </IfDefine> 
     <IfDefine !APACHE24> 
      Order Deny,Allow 
      Deny from all 
      Allow from 127.0.0.0/8 localhost ::1 192.168.1 
     </IfDefine> 
    </Directory> 
</VirtualHost> 
+0

謝謝,這實際上工作。單獨更新'httpd.conf'並沒有幫助,但是當我在'httpd-vhost.conf'中添加更改時,它工作正常。 – Steven 2014-12-02 07:46:56

+0

你聽起來很驚訝嗎? – RiggsFolly 2014-12-02 08:55:45

+0

是的,因爲直到現在我只需要在主配置中配置'',而不是爲每個虛擬主機添加它。 – Steven 2014-12-03 18:30:35

相關問題