우분투 아파치 WebDAV 설정

(아파치 mod dav 설정에서 넘어옴)

1 개요[ | ]

아파치 WebDAV 설정

2 사전 작업[ | ]

3 아파치 모듈 확인[ | ]

root@zetawiki:~# apachectl -D DUMP_MODULES | grep dav
root@zetawiki:~#

4 dav_fs 모듈 활성화[ | ]

root@zetawiki:~# a2enmod dav_fs
Considering dependency dav for dav_fs:
Enabling module dav.
Enabling module dav_fs.
To activate the new configuration, you need to run:
  service apache2 restart
root@zetawiki:~# apachectl -D DUMP_MODULES | grep dav
 dav_module (shared)
 dav_fs_module (shared)
Syntax OK

5 패스워드 파일 생성[ | ]

root@zetawiki:~# htpasswd -c /etc/apache2/webdav.pwd testuser
New password: P@ssw0rd
Re-type new password: P@ssw0rd
Adding password for user testuser

6 webdav 폴더, 테스트 파일 생성[ | ]

root@zetawiki:~# mkdir /var/www/webdav
root@zetawiki:~# echo hello > /var/www/webdav/greet.txt
root@zetawiki:~# chown -R www-data. /var/www/webdav/
root@zetawiki:~# ll /var/www/webdav/
total 12
drwxr-xr-x 2 www-data www-data 4096 Jun 21 17:22 ./
drwxr-xr-x 5 root     root     4096 Jun 21 17:22 ../
-rw-r--r-- 1 www-data www-data    6 Jun 21 17:22 greet.txt

7 아파치 설정파일 수정, 재시작[ | ]

root@zetawiki:~# vi /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
... (생략)
	Alias /webdav /var/www/webdav
	<Location /webdav>
		DAV On
		AuthType Basic
		AuthName "== My First WebDAV =="
		AuthUserFile /etc/apache2/webdav.pwd
		Require valid-user
	</Location>
	<Directory /var/www/webdav>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  • 아파치 재시작
root@zetawiki:~# service apache2 restart
 * Restarting web server apache2                                                    [ OK ]

8 curl 테스트[ | ]

  • 헤더 확인
root@zetawiki:~# curl -I http://localhost/webdav
HTTP/1.1 401 Unauthorized
Date: Sun, 01 May 2016 07:51:47 GMT
Server: Apache/2.4.7 (Ubuntu)
WWW-Authenticate: Basic realm="== My First WebDAV =="
Content-Type: text/html; charset=iso-8859-1
  • 업로드 테스트
root@zetawiki:~# echo world > greet2.txt
root@zetawiki:~# curl -u testuser:P@ssw0rd -T greet2.txt http://localhost/webdav/greet2.txt
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>
root@zetawiki:~# ll /var/www/webdav/
total 16
drwxr-xr-x 2 www-data www-data 4096 Jun 21 17:33 ./
drwxr-xr-x 5 root     root     4096 Jun 21 17:22 ../
-rw-r--r-- 1 www-data www-data    6 Jun 21 17:33 greet2.txt
-rw-r--r-- 1 www-data www-data    6 Jun 21 17:22 greet.txt

9 (Optional) cadaver 테스트[ | ]

root@zetawiki:~# cadaver http://localhost/webdav
Authentication required for == My First WebDAV == on server `localhost':
Username: testuser
Password: P@ssw0rd
dav:/webdav/> ls
Listing collection `/webdav/': succeeded.
        greet.txt                              6  Dec 14 15:11
dav:/webdav/> cat greet.txt 
Displaying `/webdav/greet.txt':
hello
dav:/webdav/> quit
Connection to `localhost' closed.
root@zetawiki:~#

10 같이 보기[ | ]

11 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}