师哥 发表于 2022-10-12 21:44:17

apache怎么开启webdav

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

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

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

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

Alias /webdav "/home"

<Directory "/usr/local/apache/uploads">
    Dav On

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

    # Allow universal read-access, but writes are restricted
    # to the admin user.
    <RequireAny>
      Require method GET POST OPTIONS
      Require user admin
    </RequireAny>
</Directory>

#
# The following directives disable redirects on non-GET requests for
# a directory that does not include the trailing slash.This fixes a
# problem with several clients that do not appropriately handle
# redirects for folders with DAV methods.
#
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1." redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
BrowserMatch " Konqueror/4" redirect-carefully



licess 发表于 2022-10-13 14:00:54

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

配置的基本类似:
<IfModule mod_dav.c>
Alias /test "/home/wwwroot"
<Directory /home/wwwroot>
    Dav On
    Options +Indexes
    IndexOptions FancyIndexing
    AddDefaultCharset UTF-8
    AuthType Basic
    AuthName "WebDAV Server"
    AuthUserFile /usr/local/apache/conf/test.pwd
    Require valid-user
    Order allow,deny
    Allow from all
</Directory>
</IfModule>
密码生成:/usr/local/apache/bin/htpasswd -c /usr/local/apache/conf/test.pwd test

师哥 发表于 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都无法连接成功

licess 发表于 2022-10-14 16:26:44

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

该启用的模块都去掉注释了吗?重启apache报错吗?

师哥 发表于 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都正常

licess 发表于 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
这个也要注释掉,不然启动会报错。写在这里记录一下,方便其他人:lol
页: [1]
查看完整版本: apache怎么开启webdav