This tutorial assumes apache running on IP 192.168.0.100 and configured according to this
2. Create required directories. /home/webdav will be used to serve files, /var/log/httpd/webdav/ will be used to keep logs and DAVLock file.
1 2 | mkdir /home/webdav mkdir -p /var/log/httpd/webdav/ |
3. Assign correct privileges
3 4 | chown -R apache:apache /home/webdav/ chown -R apache:apache /var/log/httpd/webdav/ |
4. Create a user who will be able to access webdav share and configure access file
5 6 7 8 9 | touch /etc/httpd/conf/user.passwd htpasswd -n tuxoz New password: Re-type new password: tuxoz:xrzE.fFDhtmwDz |
5.Copy the username:password and paste it in the access file
10 | vi /etc/httpd/conf/user.passwd |
6. Create a new virtual host
11 12 | cd /etc/httpd/conf/vhost/ vi domain.com.conf |
<VirtualHost 192.168.0.100:80> ServerAdmin admin@domain.com DocumentRoot /var/www/domain.com/ ServerName www.domain.com ErrorLog /var/logs/httpd/domain.com.error_log CustomLog /var/logs/httpd/domain.com.access_log combined ErrorDocument 404 / <Directory "/var/www/domain.com/"> Options Indexes FollowSymLinks AllowOverride None Order deny,allow Allow from all </Directory> <Directory "/home/webdav/"> Options none # Options Indexes FollowSymLinks - if you want to see it in webrowser AllowOverride None Order allow,deny Allow from all </Directory> Alias /webdav /home/webdav/ <Location /webdav> DAV On AuthType Basic AuthName DAV AuthUserFile /etc/httpd/conf/user.passwd <LimitExcept GET HEAD OPTIONS> require user tuxoz </LimitExcept> </Location> DAVLockDB /var/logs/httpd/webdav/DAVLock </VirtualHost>
Explanation:
part1. This part takes care of your regular apache website, any files ( ex. index.html ) placed in /var/www/domain.com/ directory will be displayed by pointing webrowser to www.domain.com
<VirtualHost 192.168.0.100:80> ServerAdmin admin@domain.com DocumentRoot /var/www/domain.com/ ServerName www.domain.com ErrorLog /var/logs/httpd/domain.com.error_log CustomLog /var/logs/httpd/domain.com.access_log combined ErrorDocument 404 / <Directory "/var/www/domain.com/"> Options Indexes FollowSymLinks AllowOverride None Order deny,allow Allow from all </Directory>
part2. This part is responsible for serving the webdav part:
- /home/webdav / is the directory where the webdav files are saved
- Use – “Options none” if you don’t want the browser to display your webdav files, use “Options Indexes FollowSymLinks” if you want to see them in the browser.
- location of the password file, /etc/httpd/conf/user.passwd
- specify the user allowed to acess webdav, “require user tuxoz”
- location of the DAVLock; “DAVLockDB /var/log/httpd/webdav/DAVLock” this must be writable by the user running apache (most likely apache:apache)
<Directory "/home/webdav/"> Options none # Options Indexes FollowSymLinks - if you want to see it in webrowser AllowOverride None Order allow,deny Allow from all </Directory> Alias /webdav /home/webdav/ <Location /webdav> DAV On AuthType Basic AuthName DAV AuthUserFile /etc/httpd/conf/user.passwd <LimitExcept GET HEAD OPTIONS> require user tuxoz </LimitExcept> </Location> DAVLockDB /var/log/httpd/webdav/DAVLock </VirtualHost>