最近在項目中須要經過WebDav方式提供文件發佈的功能,特此記錄配置全過程。Apache2內置直接支持WebDav功能,開啓並配置便可,配置過程以下(注:這裏使用了xampp集成的apache,與獨立安裝的配置略有差別): web
一、開啓WebDav
修改httpd.conf文件,找到以下行,去掉Include前面的#
shell
# Distributed authoring and versioning (WebDAV) Include etc/extra/httpd-dav.conf
DavLockDB "/opt/lampp/var/DavLock" Alias /webdav"/opt/lampp/webdav" #訪問路徑及別名 <Directory "/opt/lampp/webdav"> Dav On Options Indexes #開啓Web頁面的直接訪問 Order Allow,Deny Allow from all AuthType Digest AuthName DAV-upload # You can use the htdigest program to create the password database: # htdigest -c "/opt/lampp/user.passwd" DAV-upload admin AuthUserFile "/opt/lampp/user.passwd" AuthDigestProvider file # Allow universal read-access, but writes are restricted # to the admin user. <RequireAny> Require method GET POST OPTIONS Require user admin </RequireAny> </Directory>
sudo chown daemon.daemon -R var sudo chown daemon.daemon -R webdav
sudo htpasswd -c user.passwd admin建立完成後便可經過http://localhost/webdav進行訪問了