2009年10月20日 星期二

安裝與設定 apache 2.2 with WebDAV and AuthType=Digest

如果你要設定把Apache的AuthType設為Digest,要注意:
1. 你的Apache 版本,不同版本設定很不一樣: http://httpd.apache.org/docs/ 查mod_auth_digest
2. 非常tricky的地方(文件沒提到): AuthName 要設得跟 realm 一樣,不然會總是認證失敗!

=====

安裝:
sudo apt-get update
sudo apt-get install apache2 php5 libapache2-mod-php5 apache2-utils

設定
1) 啟用WebDAV
sudo a2enmod dav_fs
sudo a2enmod dav
sudo a2enmod dav_lock
sudo a2enmod auth_digest

2) 建立 WebDAV 使用者 (舉例:使用者 robertDAV)
sudo htdigest -c /etc/apache2/.digestpwd.dav /davshared/ robertdav
(Basic認證才用 htpasswd )
(如果有兩組以上user要設定,可能要手動填第二行喔!不然第二次使用htdigest會把第一組的資料"切掉")

3) 建立共享的 WebDAV 目錄
sudo mkdir /var/www/davshared/
sudo chown www-data:www-data /var/www/davshared/

4) 設定apache config 關於 WebDAV 目錄位置、權限等
vim /etc/apache2/sites-available/default
插入:

(請自動把以下的( )換成< >,因打< >在此秀不出來)
Alias /davshared/ "/var/www/davshared/"
(Directory "/var/www/davshared/")
       Options Indexes FollowSymLinks MultiViews
       AllowOverride None
       Order allow,deny
       allow from all
       #Allow from 192.168.0.0/255.0.0.0 ::1/128
(/Directory)
(Location /davshared/)
       DAV On
       AuthName "/davshared/"
       #AuthType Basic
       #AuthUserFile /etc/apache2/.passwd.dav
       AuthType Digest
       AuthDigestProvider file
       AuthDigestDomain /davshared/
       AuthUserFile /etc/apache2/.digestpwd.dav
       DavMinTimeout 600
       #(LimitExcept GET PUT HEAD OPTIONS POST)
       (LimitExcept GET HEAD OPTIONS)
               Require valid-user
       (/LimitExcept)
(/Location)



5) 重啟 apache
sudo /etc/init.d/apache2 restart

========================
Reference:
Setting up a WebDAV server
http://www.linuxquestions.org/questions/linux-server-73/digest-authentication-not-working-on-default-apache-installation-on-slackware-12.1-730785/
http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html
http://samiux.wordpress.com/2009/06/27/howto-webdav-on-ubuntu-9-04-server/

沒有留言:

張貼留言