2010-11-27 58 views
1

我一直在測試Apache身份驗證的用法,在此之後exampleApache禁止

我正在使用Ubuntu/Apache2。

在我的 '網站',在/ etc/apache2的/啓用的站點 -/playcat,其指向將/ home/playcat /的public_html,我進入了以下內容:

<Directory "/home/playcat/public_html/backend"> 
    AuthType Basic 
    AuthName "Restricted Content" 
    AuthBasicProvider file 
    AuthUserFile /home/playcat/passwd/passwords 
    Require user playcat 
</Directory> 

密碼用戶playcat創建通過

htpasswd -c /home/playcat/passwd/passwords playcat 

很明顯,在此之前,我創建了passwd文件夾:)。

現在,當我打開http://localhost/backend,我得到了u/p組合的提示。但是,當我輸入它時,我得到403響應。

除此之外,服務器正在工作。我安裝了PHP和MySQL,並且一切正常。

我錯過smt嗎?

Thx

p.s.我使用正確的用戶名/密碼組合:)

回答

0

嘗試改變

<Directory "/home/playcat/public_html/backend"> 

<Directory /home/playcat/public_html/backend> 

這就是它應該如何根據規範寫成:

http://httpd.apache.org/docs/current/mod/core.html#directory

這是一個適合我的例子:

<Directory /path/to/web/site/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 

    Order deny,allow 
    AuthType Basic 
    AuthName "Restricted Files" 
    # (Following line optional) 
    AuthBasicProvider file 
    AuthUserFile /path/to/htpasswd 
    Require valid-user 
    </Directory> 
+0

謝謝,這是做的工作。另外,我忘了爲文件夾設置755 *腮紅* – hummingBird 2010-11-27 17:21:42