在本文中我使用的是自己编译的`httpd 2.4`。以下是我的`mod_dav`配置:
[weli@dhcp-66-78-87 httpd]$ cat conf.d/00-dav.conf
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dav_lock_module modules/mod_dav_lock.so
<IfModule mod_dav_fs.c>
Location of the WebDAV lock database.
DAVLockDB /var/lib/dav24/lockdb
</IfModule>
Alias /davfoo /home/weli/projs/httpd/www/davfoo
<Location /davfoo>
DAV On
</Location>
<Directory /davfoo>
Options Indexes MultiViews
Require all granted
</Directory>
注意`DAVLockDB`和`DAV On`的目录,httpd一定要有写权限。在我的httpd配置中,服务器运行时所属的用户和用户组是`apache/apache`:
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache
因此对于`mod_dav`来讲,`DAVLockDB`和`DAV On`的目录要对apache用户或用户组有写权限:
[weli@dhcp-66-78-87 httpd]$ sudo namei -mo /var/lib/dav24
f: /var/lib/dav24
dr-xr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwx------ apache apache dav24
[weli@dhcp-66-78-87 httpd]$ namei -mo www/davfoo
f: www/davfoo
drwxr-xr-x weli weli www
drwxr-xr-x apache apache davfoo
配置完成后启动httpd。我们可以使用cadaver这个工具来做测试:
可以试着上传和下载文件:
以上是`mod_dav`的基本使用方法。