WebDAV, also known as “Web-based Distributed Authoring and Versioning”, is an extension of the Hypertext Transfer Protocol. It allows users to collaboratively edit and manage files on a remote web server using HTTP protocol. You can share Word or Excel documents or a music collection with your friends and other people by simply giving them a URL. WebDAV also allow us to upload and download files on the Apache server. There are several benefits of WebDAV over other solutions such as FTP or Samba.
In this article I will explain how to install and configure WebDav with the Apache2 Web Server on Ubuntu-14.04.
Installing WebDAV
By default the WebDAV module comes with apache2 installation in Ubuntu-14.04. However, it is not enabled by default.
You need to enable it first. You can enable the WebDAV modules using the a2enmod
command.
sudo a2enmod dav sudo a2enmod dav_fs
This will create a symbolic link from “/etc/apache2/mods-available” to “/etc/apache2/mods-enabled.”
Now, restart Apache to activate the new configuration.
sudo /etc/init.d/apache2 restart
Configure WebDav Directory
After enabling the module, you will need to create the required directory where you will configure webdav.
Now, create a directory under Apache web root.
sudo mkdir /var/www/html/webdav
You will also need to change the permission in order to allow Apache to write to it.
sudo chown -R www-data:www-data /var/www/html/webdav
Setting Password Protection
A WebDAV server without authentication is not secure. It is recommended to add authentication to your WebDAV server.
You need to create an authentication procedure for accessing the directory content by creating an htpasswd file.
Create a hidden .htpasswd file in the “/etc/apache2” configuration directory with the user “webuser.”
sudo htpasswd -c /etc/apache2/.htpasswd webuser
Now you need to assign group ownership of the file to “www-data,” and then lock down the permissions for everyone else:
sudo chown www-data:www-data /etc/apache2/.htpasswd sudo chmod 640 /etc/apache2/.htpasswd
Configure Virtual Host
Next, you need to create a virtual host file for the webdav directory.
To do so, navigate to “/etc/apache2/sites-available/”:
cd /etc/apache2/sites-available/
Create a new site configuration file called “webdev.conf.”
sudo nano /etc/apache2/sites-available/webdav.conf
Add the following content:
DavLockDB /var/www/html/DavLock <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/webdav/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /webdav /var/www/html/webdav <Directory /var/www/html/webdav> DAV On AuthType Basic AuthName "webdav" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Directory> </VirtualHost>
After creating the virtual host files, you need to enable a new virtual host.
You can do this by running:
sudo a2ensite webdav.conf
Now, restart Apache to activate the new configuration.
sudo /etc/init.d/apache2 restart
Testing WebDav Using a Web Browser
Finally, you need to test whether WebDav is properly enabled or not.
Open your favorite web browser and navigate to the url “http://your-server-ip/webdav/.” You will be prompted with a username and password to access the web page.
Testing WebDav Using File Manager
On your Ubuntu Linux machine, open the file manager and press the “Connect to Server” option on the left sidebar. Type the server address “dav://your-server-ip/webdav/,” and press Enter.
You will be prompted for a username and password. Enter them and press Connect.
Once you have connected, the directory should appear under the file manager.
Conclusion
In this article we have gone through how to configure webdav with the Apache server. Now, you have enough knowledge to configure it in production environment. Feel free to comment below if you have any questions.
Over 5 years of experience as IT system administrator for IT company in India. My skills include a deep knowledge of Rehat/Centos, Ubuntu nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, squied proxy, NFS, FTP, DNS, Samba, ldap, Openvpn, Haproxy, Amazon web services, WHMCS, Openstack Cloud, Postfix Mail Server, Security etc.
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe