How To Set Up WebDAV With Apache2 On Ubuntu 14.04 Server
Sponsored Link
The WebDAV protocol makes the Web a readable and writable medium.It provides a framework for users to create, change and move documents on a server; typically a web server or web share. The most important features of the WebDAV protocol include the maintenance of properties about an author or modification date, namespace management, collections, and overwrite protection. Maintenance of properties includes such things as the creation, removal, and querying of file information. Namespace management deals with the ability to copy and move web pages within a server’s namespace. Collections deal with the creation, removal, and listing of various resources. Lastly, overwrite protection handles aspects related to locking of files.
Prerequisite
Ubuntu 14.04 server installation and we are going to use the server ip 192.168.56.101
Install apache2 server using the following command
sudo apt-get install apache2 apache2-utils
Install required modules using the following commands
sudo a2enmod dav
sudo a2enmod dav_fs
Restart Apache2 using the following command
sudo service apache2 restart
Apache2 Virtualhost Configuration
We will now create a default Apache vhost in the directory /var/www/webdav . For this purpose,we will modify the default Apache vhost configuration in /etc/apache2/sites-available/000-default.conf.
First, we create the directory /var/www/webdav and make the Apache user (www-data) the owner of that directory
sudo mkdir -p /var/www/webdav
sudo chown www-data /var/www/webdav
Now we need to edit the /etc/apache2/sites-available/000-default.conf file
sudo vi /etc/apache2/sites-available/000-default.conf
Add the following information
NameVirtualHost *
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/webdav/
<Directory /var/www/webdav/>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Restart Apache2 using the following command
sudo service apache2 restart
Configure The Virtual Host For WebDAV
Now we create the WebDAV password file /var/www/webdav/passwd.dav with the user andy
sudo htpasswd -c /var/www/webdav/passwd.dav andy
You will be asked to type in a password for the user andy.
Now we change the permissions of the /var/www/webdav/passwd.dav file so that only root and the members of the www-data group can access it:
sudo chown root:www-data /var/www/webdav/passwd.dav
sudo chmod 640 /var/www/webdav/passwd.dav
Now we modify our vhost in /etc/apache2/sites-available/000-default.conf and add the following lines
Alias /webdav /var/www/webdav
<Location /webdav>
DAV On
AuthType Basic
AuthName "webdav"
AuthUserFile /var/www/webdav/passwd.dav
Require valid-user
</Location>
Restart Apache2 using the following command
sudo service apache2 restart
Testing WebDAV
We will now install cadaver, a command-line WebDAV client using the following command
sudo apt-get install cadaver
To test if WebDAV works, type the following command
cadaver http://192.168.56.101/webdav/
Output Looks as follows
root@ubuntu-VirtualBox:~# cadaver http://192.168.56.101/webdav/
Authentication required for webdav on server `192.168.56.101′:
Username: andy
Password:
dav:/webdav/>
Worked for me. Thank you for the tutorial!
Hi,
following you instructions and runing fine, thank you very much, but i have some confusion about passwd.dav at the root folder.
great, tried over and over with other sites but lots of problems mostly involving rights.
this one worked right on except for the Set the,’ServerName’ directive globally to suppress this message error.
thanks a bunch