How To Set Up WebDAV With Apache2 On Fedora 11
Author: Falko Timme
Follow me on Twitter
This guide explains how to set up WebDAV with Apache2 on a Fedora 11 server. WebDAV stands for Web-based Distributed Authoring and Versioning and is a set of extensions to the HTTP protocol that allow users to directly edit files on the Apache server so that they do not need to be downloaded/uploaded via FTP. Of course, WebDAV can also be used to upload and download files.
I do not issue any guarantee that this will work for you!
1 Preliminary Note
I'm using a Fedora 11 server with the IP address 192.168.0.100 here.
2 Installing WebDAV
If Apache is not already installed, install it as follows:
yum install httpd
Afterwards, open /etc/httpd/conf/httpd.conf and make sure that the dav and dav_fs modules are enabled in the LoadModule section (they should be enabled by default):
[...] LoadModule dav_module modules/mod_dav.so [...] LoadModule dav_fs_module modules/mod_dav_fs.so [...]
Then create the system startup links for Apache and start it:
chkconfig --levels 235 httpd on
3 Creating A Virtual Host
I will now create a default Apache vhost in the directory /var/www/web1/web. For this purpose, I will add a default vhost at the end of /etc/httpd/conf/httpd.conf. If you already have a vhost for which you'd like to enable WebDAV, you must adjust this tutorial to your situation.
First, we create the directory /var/www/web1/web and make the Apache user and group (apache) the owner of that directory:
mkdir -p /var/www/web1/web
chown apache:apache /var/www/web1/web
Then add the new vhost at the end of /etc/httpd/conf/httpd.conf:
[...] NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/web1/web/ <Directory /var/www/web1/web/> Options Indexes MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost>
Then reload Apache:
4 Configure The Virtual Host For WebDAV
Now we create the WebDAV password file /var/www/web1/passwd.dav with the user test (the -c switch creates the file if it does not exist):
htpasswd -c /var/www/web1/passwd.dav test
You will be asked to type in a password for the user test.
(Please don't use the -c switch if /var/www/web1/passwd.dav is already existing because this will recreate the file from scratch, meaning you lose all users in that file!)
Now we change the permissions of the /var/www/web1/passwd.dav file so that only root and the members of the apache group can access it:
chown root:apache /var/www/web1/passwd.dav
chmod 640 /var/www/web1/passwd.dav
Now we modify our vhost at the end of /etc/httpd/conf/httpd.conf and add the following lines to it:
[...] Alias /webdav /var/www/web1/web <Location /webdav> DAV On AuthType Basic AuthName "webdav" AuthUserFile /var/www/web1/passwd.dav Require valid-user </Location> [...]
The Alias directive makes (together with <Location>) that when you call /webdav, WebDAV is invoked, but you can still access the whole document root of the vhost. All other URLs of that vhost are still "normal" HTTP.
The final vhost should look like this:
[...] NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/web1/web/ <Directory /var/www/web1/web/> Options Indexes MultiViews AllowOverride None Order allow,deny allow from all </Directory> Alias /webdav /var/www/web1/web <Location /webdav> DAV On AuthType Basic AuthName "webdav" AuthUserFile /var/www/web1/passwd.dav Require valid-user </Location> </VirtualHost>
Reload Apache afterwards:
5 Testing WebDAV
We will now install cadaver, a command-line WebDAV client:
yum install cadaver
To test if WebDAV works, type:
You should be prompted for a user name. Type in test and then the password for the user test. If all goes well, you should be granted access which means WebDAV is working ok. Type quit to leave the WebDAV shell:
[[email protected] ~]# cadaver http://localhost/webdav/
Authentication required for webdav on server `localhost':
Connection to `localhost' closed.
[[email protected] ~]#