2013-08-23 78 views
348

嘗試通過瀏覽器訪問本地主機時出現此錯誤。Apache2:'AH01630:被服務器配置拒絕的客戶端'

AH01630: client denied by server configuration 

我檢查使用我的網站文件夾的權限:

sudo chmod 777 -R * 

這裏是我的配置文件:

<VirtualHost *:80> 
ServerAdmin [email protected] 

DocumentRoot /home/user-name/www/myproject 
<Directory /> 
    Options FollowSymLinks 
    AllowOverride all 
    Allow from all 
</Directory> 

<Location /> 
    Allow from all 
    Order Deny,Allow 
</Location> 

<Directory /home/user-name/www/myproject/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride all 
    Order allow,deny 
    Allow from all 
</Directory> 

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
<Directory "/usr/lib/cgi-bin"> 
    AllowOverride all 
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
    Order allow,deny 
    Allow from all 
</Directory> 

ErrorLog ${APACHE_LOG_DIR}/error.log 

# Possible values include: debug, info, notice, warn, error, crit, 
# alert, emerg. 
LogLevel warn 

CustomLog ${APACHE_LOG_DIR}/access.log combined 

Alias /doc/ "/usr/share/doc/" 
<Directory "/usr/share/doc/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride all 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.0/255.0.0.0 ::1/128 
</Directory> 

+1

你使用的是新的Apache 2.4嗎?哪條路徑給出了這個錯誤? – aadel

+0

是的,Apache 2.4,當我試圖瀏覽應用程序目錄中的任何文件 –

+10

時發生這種情況看起來您需要更新您的配置。 看看這裏:http://httpd.apache.org/docs/2.4/upgrading.html#run-time – aadel

回答

634

如果您使用的是Apache 2.4

你必須檢查允許和否認規則

退房http://httpd.apache.org/docs/2.4/upgrading.html#access

在2.2的基礎上,客戶端的主機名,IP地址,客戶端請求的其他特性 訪問控制使用指令 訂單,允許,拒絕做,最大限度的滿足。

在2.4中,使用新模塊mod_authz_host以與其他 授權檢查相同的方式完成此類訪問控制。

新指令爲Require

2.2配置:

Order allow,deny 
Allow from all 

2.4配置:

Require all granted 

也不要忘記這些更改後重新啓動Apache服務器( # service httpd restart

+2

OSX 10.10使用Apache 2.4 Yosemite的作品 –

+2

*什麼*(即「要求所有授予」在哪裏去?在某些.conf文件中?) – Alexis

+1

@Alexis目錄(或位置)的配置。在下一個答案中看截圖。 – strangeman

4

如果尾巴錯誤日誌並重新加載頁面,你應該看到更多關於確切問題的信息。

抓住環境變量,那麼$ {} APACHE_LOG_DIR將實際工作...

source /etc/apache2/envvars 

然後尾巴,看...

tail -f ${APACHE_LOG_DIR}/error.log 
+4

這是來自日誌的錯誤:'AH01630:客戶端被服務器配置拒絕' –

+0

您可能需要檢查:http://httpd.apache.org/docs/2.4/upgrading.html#access並且這個: http://stackoverflow.com/questions/12759854/client-denied-by-server-configuration-while-trying-to-use-git-http-backend-exe –

+4

如果您將'LogLevel debug'添加到VirtualHost中,這是好的建議,因爲你會看到像「要求所有被拒絕:被拒絕」和「:被拒絕」(即比「服務器配置拒絕的客戶端」更有用的行,因爲它實際上告訴你*哪個配置! ) –

23

仔細檢查DocumentRoot路徑是否正確。這可能會導致此錯誤。

+3

更具體地說,我發現這是我的問題,因爲我的DocumentRoot聲明中沒有結尾斜槓,但確實在''塊中使用了一個斜槓。我也有一些情況差異。一旦我將這兩個值互相拷貝(沒有尾隨斜線),它就完美運作了。 –

285

對於所有目錄寫Require all granted代替Allow from all Something like

更新

如果以上不工作,然後還刪除此下面提到行:

訂購允許,拒絕

+12

一旦我刪除了'Order allow,deny'行,就爲我工作了。 – kasperd

+16

'要求所有授予'爲我做了,謝謝! – FloatingRock

+0

注意:在使用** HTTPS **時,爲端口** 443 **配置** VirtualHost **,我必須在'default-ssl上覆制相同的配置'要求所有授權的'。 conf'爲我的CSS被加載。 (我的問題是登錄頁面是可訪問的,但沒有CSS或其他媒體文件被加載......) – yuric

18

我做了與rackerg向OSX 10.10 Yosemite建議的將Apache升級到2.4的相同更改。以下是添加到http.conf的更改。

<Directory /> 
    AllowOverride none 
    Require all denied 
</Directory> 

<Directory /Volumes/Data/Data/USER/Sites/> 
    AllowOverride none 
    Require all granted 
</Directory> 
10

這讓我絕對堅持了一天半,但如果所有其他解決方案都嘗試失敗,我發現了一個解決方案。

  • 去活動監控(聚光燈搜索:活動)
  • 在活動監控器搜索的httpd是Apache服務
  • 選擇屬於root,並單擊X左上方關閉一個它。

在這一點上,我立即停止了403錯誤,一切開始按預期工作。奇怪的是,我甚至沒有重新啓動Apache,它只是工作,我想它重新啓動時,我去我的本地主機,我真的不知道,但我想問題是Apache沒有實際重新啓動時使用apachectl重新啓動,或停止或開始。希望這可以幫助某人。

+1

浪費時間之後,這也解決了我的問題。 –

3

花了幾個小時後,我解決了自己的問題。

我通過coookbook在vagrant vm中安裝了Apache/2.4.7(Ubuntu)。

/etc/apache2/apache2.conf文件默認沒有<VirtualHost *:80>元素。

我做了兩個轉變把它做

  1. 添加<VirtualHost *:80>
  2. 添加
    選項指標的FollowSymLinks
    的AllowOverride所有
    所有

然後最後我剛纔啓動VM允許..

3

有沒有人想過這個wamp服務器默認不包含httpd-vhosts.conf文件。 我的做法是在httpd.conf文件中刪除以下

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

的說明。 就是這樣。

+0

+1這也適用於我,但也許更好的解決方案是保持'conf/extra/httpd-vhosts.conf'文件並替換爲'Require local'和'Require all granted' –

2

這讓我瘋狂。最後找出問題所在: 我使用直接路徑作爲錯誤日誌,它們是錯誤的。

爲什麼Apache會給出一個模糊的錯誤信息?請使用正確且有用的錯誤消息,如:ErrorLog指令的路徑「/wrong/path/and/filename.log」無效。

總之,要解決請確保您的錯誤日誌指令是這個樣子:

ErrorLog ${APACHE_LOG_DIR}/error.log 
CustomLog ${APACHE_LOG_DIR}/access.log combined 
1

如果您有HTTPS主機的話,不要忘記做出SSL配置Require all granted變化太大。

此外,有時是非常有用的檢查權限爲apache用戶:

# ps -eFH | grep http # get the username used by httpd 
... 
apache 18837 2692 0 119996 9328 9 10:33 ?  00:00:00  /usr/sbin/httpd -DFOREGROUND 
# su -s/bin/bash apache # switch to that user 
bash-4.2$ whoami 
apache 
bash-4.2$ cd /home 
bash-4.2$ ls 
bash-4.2$ cd mysite.com 
bash-4.2$ ls 
bash-4.2$ cat file-which-does-not-work.txt 
1

對於WAMP 3(阿帕奇2.4),除了把服務器聯機如其他答案描述的,在虛擬主機文件conf/extra/httpd-vhosts.conf
你可能需要更換

Require local 

Require all granted 



這是適用的,如果在httpd.conf你有

Include conf/extra/httpd-vhosts.conf 
2

的問題是虛擬主機,但probablely不是

要求所有授予

確認你的配置是正確的,這裏是正確的樣本 enter image description here

0

除了缺少其他的答案中提到OrderAllow指令要知道,一個DirectoryMatch指令的非匹配的正則表達式也可能導致此錯誤。

如果請求的路徑是/home/user-foo1bar/www/myproject/的folloing匹配不匹配

<DirectoryMatch "/home/user-[a-z]+/www/myproject/"> 
... 
</DirectoryMatch> 

因此,即使是有效的訪問配置可能會導致這個錯誤。

相關問題