首先安装好你的apache服务
启动webdav
sudo a2enmod dav_fs
sudo a2enmod dav
创建一个可以共享目录并授权给apache;
sudo mkdir /var/www/webdav
sudo chown www-data:www-data /var/www/webdav
sudo mkdir /var/www/webdavpasswd
创建一个存放密码的目录并创建登陆用户
#创建用户
sudo htpasswd -c /var/www/webdavpasswd/passwd.dav admin
#授权密码目录给apache
sudo chown www-data:www-data -R /var/www/webdavpasswd
#设置密码文件读写权限
sudo chmod 640 /var/www/webdavpasswd/passwd.dav
最后写入Apache2配置文件;重启一下apache就OK了
vi /etc/apache2/sites-enabled/000-default.conf
重启服务
service apache2 restart
访问webdav 目录需要账号密码 可以用作文件的上传
webdav/resource 目录可以作为外部访问的目录其为匿名访问
DavLockDB /var/www/DavLock
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Alias /webdav /var/www/webdav #别名
<Directory /var/www/webdav> #访问路径
Dav On #开启webdav
Options +Indexes
IndexOptions FancyIndexing
AddDefaultCharset UTF-8
AuthType Basic
AuthName "WebDAV Server"
AuthUserFile /var/www/webdavpasswd/passwd.dav #访问用户文件
Require valid-user #访问用户
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/webdav/resource"> #匿名用户访问
Dav On
Options Indexes FollowSymLinks Includes
Order Deny,Allow
Allow from all
AllowOverride none
AuthType Basic
AuthName AirDisk
AuthUserFile "/usr/mips/user.passwd"
<Limit PUT POST MOVE DELETE MKCOL> #仅对指定的方法进行访问限制
require user xxx #只能xxx用户才能使用 <Limit> 所限制的请求方法,其他用户都无法使用,而xxx用户又不存在user.passwd里,所有限制了所有用户修改该目录。
</Limit>
</Directory>
</VirtualHost>