VPS侦探论坛

 找回密码
 注册
查看: 2446|回复: 6

apache怎么开启webdav

[复制链接]
发表于 2022-10-12 21:44:17 | 显示全部楼层 |阅读模式

也是看到论坛的帖子,看了这个教程 https://cnzhx.net/blog/configuration-of-webdav-on-apache/

配置后打开webdav链接是404
账号我也添加了,账号是 admin 密码文件也自动生成成功
  1. #
  2. # Distributed authoring and versioning (WebDAV)
  3. #
  4. # Required modules: mod_alias, mod_auth_digest, mod_authn_core, mod_authn_file,
  5. #                   mod_authz_core, mod_authz_user, mod_dav, mod_dav_fs,
  6. #                   mod_setenvif

  7. # The following example gives DAV write access to a directory called
  8. # "uploads" under the ServerRoot directory.
  9. #
  10. # The User/Group specified in httpd.conf needs to have write permissions
  11. # on the directory where the DavLockDB is placed and on any directory where
  12. # "Dav On" is specified.

  13. DavLockDB "/usr/local/apache/var/DavLock"

  14. Alias /webdav "/home"

  15. <Directory "/usr/local/apache/uploads">
  16.     Dav On

  17.     AuthType Basic
  18.     AuthName DAV
  19.     # You can use the htdigest program to create the password database:
  20.     #   htdigest -c "/usr/local/apache/user.passwd" DAV-upload admin
  21.     AuthUserFile "/usr/local/apache/user.passwd"
  22.     AuthDigestProvider file

  23.     # Allow universal read-access, but writes are restricted
  24.     # to the admin user.
  25.     <RequireAny>
  26.         Require method GET POST OPTIONS
  27.         Require user admin
  28.     </RequireAny>
  29. </Directory>

  30. #
  31. # The following directives disable redirects on non-GET requests for
  32. # a directory that does not include the trailing slash.  This fixes a
  33. # problem with several clients that do not appropriately handle
  34. # redirects for folders with DAV methods.
  35. #
  36. BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
  37. BrowserMatch "MS FrontPage" redirect-carefully
  38. BrowserMatch "^WebDrive" redirect-carefully
  39. BrowserMatch "^WebDAVFS/1.[01234]" redirect-carefully
  40. BrowserMatch "^gnome-vfs/1.0" redirect-carefully
  41. BrowserMatch "^XML Spy" redirect-carefully
  42. BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
  43. BrowserMatch " Konqueror/4" redirect-carefully

复制代码


美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2022-10-13 14:00:54 | 显示全部楼层


首先不建议在这个 httpd-dav.conf 上修改,这个文件本身就只是为dav提供基本支持设置的
2,你设置本身就有问题,Directory的目录设置和前面Alias设置的目录就不一样
3,如果你设置成功了也会按你配置文件里的会出现登录验证

配置的基本类似:
  1. <IfModule mod_dav.c>
  2. Alias /test "/home/wwwroot"
  3. <Directory /home/wwwroot>
  4.     Dav On
  5.     Options +Indexes
  6.     IndexOptions FancyIndexing
  7.     AddDefaultCharset UTF-8
  8.     AuthType Basic
  9.     AuthName "WebDAV Server"
  10.     AuthUserFile /usr/local/apache/conf/test.pwd
  11.     Require valid-user
  12.     Order allow,deny
  13.     Allow from all
  14. </Directory>
  15. </IfModule>
复制代码

密码生成:/usr/local/apache/bin/htpasswd -c /usr/local/apache/conf/test.pwd test
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2022-10-13 15:46:02 | 显示全部楼层

licess 发表于 2022-10-13 14:00
首先不建议在这个 httpd-dav.conf 上修改,这个文件本身就只是为dav提供基本支持设置的
2,你设置本身就有 ...

军哥,我把代码放在了httpd.conf 文件末尾,也用命令生成了密码,也重启了httpd服务,原来的httpd-dav.conf 被我恢复成默认了,但是还是无法连接webdav,我用群晖和MAC都无法连接成功
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2022-10-14 16:26:44 | 显示全部楼层



师哥 发表于 2022-10-13 15:46
军哥,我把代码放在了httpd.conf 文件末尾,也用命令生成了密码,也重启了httpd服务,原来的httpd-dav.con ...

该启用的模块都去掉注释了吗?重启apache报错吗?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2022-10-14 20:49:34 | 显示全部楼层

licess 发表于 2022-10-14 16:26
该启用的模块都去掉注释了吗?重启apache报错吗?

启用了
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
启动Apache没有报错,web都正常

军哥运维代购:http://shop63846532.taobao.com/

发表于 2022-10-15 12:03:42 | 显示全部楼层

师哥 发表于 2022-10-14 20:49
启用了
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so

httpd.conf 中 httpd-dav.conf 该行前面的注释去掉了没?
 楼主| 发表于 2022-10-15 19:47:19 | 显示全部楼层

licess 发表于 2022-10-15 12:03
httpd.conf 中 httpd-dav.conf 该行前面的注释去掉了没?

感谢军哥,的确没去掉,去掉后就好了。
LoadModule auth_digest_module modules/mod_auth_digest.so
这个也要注释掉,不然启动会报错。写在这里记录一下,方便其他人
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-20 08:51 , Processed in 0.028219 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表