最近在项目中须要经过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进行访问了