apache 搭建webdav

首先安装好你的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 目录可以作为外部访问的目录其为匿名访问

apache webdav config


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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值