Apache WebDav服务

    为了让Apache显示能像FTP server那样的文件列表,我们可以使用Apache的WebDav的服务。

    WebDav(Web-based Distributed Authoring and Versioning)是一种基于HTTP1.1协议的通信协议,扩展了HTTP1.1,主要有GET(检索文档),PUT和POST(将文档提交到服务器),HEAD,OPTIONS和TRACE(主要由应用程序用来发现和跟踪服务器支持和网络行为),DELETE(销魂资源或集合)Mkcol(创建集合),PropFind和PropPatch(针对资源和集合检索和设置属性),Copy和Move(管理命名空间上下文中的资源和集合),Lock和Unlock(改写保护)。

   WebDav请求的一般机构遵循HTTP格式,并且由一下三个组件构成:
   1.方法,声明由客户端执行的方法
   2.标头,描述有关如何完成此任何的指令。
   3.主体(optional),定义用在该指令或者其他指令中的数据,用以描述如何完成此方法。
  
    WebDav允许客户端进行下列操作:
  
    处理服务器上 WebDAV 发布目录中的资源。使用此功能,其优点例如:
    1.具有正确权限的用户可以在 WebDAV目录中复制和移动文件。
    2.修改与某些资源相关联的属性。例如,用户可写入并检索文件的属性信息。
    3.锁定并解锁资源以便多个用户可同时读取一个文件。但每次只能有一个人修改文件。
    4.搜索 WebDAV 目录中的文件的内容和属性。

    Apache支持WebDav服务,而且配置也很简单。
    1.Enable module:
     
Java代码   收藏代码
  1. LoadModule dav_module modules/mod_dav.so  
  2. LoadModule dav_fs_module modules/mod_dav_fs.so  
  3. LoadModule dav_lock_module modules/mod_dav_lock.so  

   
    2.Remove comment out:
     
Java代码   收藏代码
  1. Include conf/extra/httpd-dav.conf  

    
    3.open http-dav.conf
     
Java代码   收藏代码
  1.  #  
  2. # Distributed authoring and versioning (WebDAV)  
  3. #  
  4. # Required modules: mod_dav, mod_dav_fs, mod_setenvif, mod_alias  
  5. #                   mod_auth_digest, mod_authn_file  
  6. #  
  7.   
  8. # The following example gives DAV write access to a directory called  
  9. "uploads" under the ServerRoot directory.  
  10. #  
  11. # The User/Group specified in httpd.conf needs to have write permissions  
  12. # on the directory where the DavLockDB is placed and on any directory where  
  13. "Dav On" is specified.  
  14.   
  15. #DavLockDB "/usr/local/apache/var/DavLock"

  16. DavLockDB "/tmp/DavLock"
  17.  
  18. Alias /webdav "/var/www/html"

  19. <Directory  "/var/www/html">
  20.     Dav On  
  21.       
  22.     Order Allow,Deny  
  23.     Allow from all  
  24.   
  25.     AuthType Digest  
  26.     AuthName DAV-upload  
  27.   
  28.     # You can use the htdigest program to create the password database:  
  29.     #   htdigest -c "/usr/local/apache/user.passwd" DAV-upload admin
  30.     AuthUserFile "/usr/local/apache/webdav.user.passwd" 
  31.     AuthDigestProvider file  
  32.   
  33.     # Allow universal read-access, but writes are restricted  
  34.     # to the admin user.  
  35.     <LimitExcept GET OPTIONS>  
  36.         require user iptv  
  37.     </LimitExcept>  
  38. </Directory>  
  39.   
  40. #  
  41. # The following directives disable redirects on non-GET requests for  
  42. # a directory that does not include the trailing slash.  This fixes a   
  43. # problem with several clients that do not appropriately handle   
  44. # redirects for folders with DAV methods.  
  45. #  
  46. BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully  
  47. BrowserMatch "MS FrontPage" redirect-carefully  
  48. BrowserMatch "^WebDrive" redirect-carefully  
  49. BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully  
  50. BrowserMatch "^gnome-vfs/1.0" redirect-carefully  
  51. BrowserMatch "^XML Spy" redirect-carefully  
  52. BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully  
  53.   
  54.         


     4.创建账户
    
Java代码   收藏代码
  1. htdigest -c "/usr/local/apache/user.passwd" DAV-upload iptv


     5. http-dav解释
        Dav on 启用WebDav服务
        Order Allow,Deny
        Allow from all   先检查禁止设定,没有禁止的全部允许
        AuthType Digest  使用Digest授权方式

        AuthUserFile    authentication的文件

        LimitExcept     除了..以外都需要校验信息

   

     6. troubleshooting

        1. /log/error_log: The locks could not be queried for verification against a possible "If:" header.  [500, #0]

            /tmp/DavLock文件所在的用户/组和httpd.conf文件里的user/group不匹配

        2. /log/error_log:  Unable to PUT new contents for /webdav/content/temp1/20130809T032258-01-270133.ts.  [403, #0]

            httpd.conf文件里的user/group没有加进apache用户组


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值