Debian Apache配置webdav
1. 启动Apache的dav服务
|
1 2 |
a2enmod dav_fs a2enmod dav |
2. 重新启动Apache
|
1 |
/etc/init.d/apache2 restart |
3. 创建文件夹, 并把文件夹的权限改为777, 文件夹的分组和所有者 都改为 www-data
|
1 2 3 |
mkdir -p 文件夹;路径 chown www-data:www-data 文件夹名称 chmod -R 777 文件夹的路径 |
4. 新建webdav.conf的文件
|
1 2 3 4 |
cd /etc/apache2/conf-available/ vim webdav.conf #vim 加入一下内容 Include /etc/apache2/webdav.d/*.conf |
5. 引入 webdav的配置文件, 并将web.dav 使用软连接 连接到conf-enabled文件夹中
|
1 2 |
cd /etc/apache2/conf-enabled/ ln -s ../conf-available/webdav.conf ./ |
6. 新建 webdav.d文件夹, 存放webdav的配置文件
|
1 |
mkdir -p /etc/apache2/webdav.d |
7. 先确认 mod_version 模块
|
1 |
apache2ctl -M | grep version |
如果显示:
|
1 |
version_module (shared) |
如果不存在:
|
1 2 |
# 开启 mod_version 模块 a2enmod version |
8. 新建all.set 和 upload.conf 的配置文件
8.1 all.set
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# Apache 2.2 / 2.4 通用 WebDAV 配置 # 必须提前加载 mod_version # 启用 WebDAV Dav On # 禁止 .htaccess 覆盖配置 AllowOverride None # 禁止 CGI 和 SSI 执行 Options -ExecCGI -Includes # Basic 身份认证 AuthType Basic AuthName "WebDAV" AuthUserFile "/etc/apache2/user.passwd" # 要求有效用户 Require valid-user # Apache 2.2 专用 <IfVersion < 2.4> Order Allow,Deny Allow from all Satisfy All </IfVersion> # 禁止通过 HTTP 访问 PHP 脚本 <FilesMatch "(?i)\.(php[0-9]?|phtml|phar)(\.|$)"> # Apache 2.2 <IfVersion < 2.4> Order Allow,Deny Deny from all </IfVersion> # Apache 2.4 <IfVersion >= 2.4> Require all denied </IfVersion> </FilesMatch> |
8.2 temp.conf
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
alias /PDF /home/upload/PDF <Directory "/home/upload"> Include "/etc/apache2/webdav.d/all.set" # 父目录不显示目录列表 Options -Indexes -ExecCGI -Includes </Directory> <DirectoryMatch "^/home/upload/[^/]+(/|$)"> # 子目录允许浏览器查看文件列表 Options +Indexes # 不寻找 index.php、index.html DirectoryIndex disabled # 强制身份认证 Require valid-user </DirectoryMatch> <LocationMatch "(?i)^/upload(/|$)"> # Apache 2.2 <IfVersion < 2.4> Order Allow,Deny Deny from all </IfVersion> # Apache 2.4 <IfVersion >= 2.4> Require all denied </IfVersion> </LocationMatch> |
9. 新建用户
|
1 2 3 4 5 |
# 创建第一个账号(密码文件不存在) htpasswd -c /etc/apache2/user.passwd root # 新增用户 # 创建第二个账号(不使用-c因为密码文件已存在) htpasswd -m /etc/apache2/user.passwd anheng # 新增用户 htpasswd -D /etc/apache2/user.passwd anheng # 删除用户 |
10. 重启 Apache的服务器