Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- webdav
- 1. What is WebDAV?
- 2. WebDAV stands for Web-based Distributed Authoring and Versioning. It was designed to allow groups of individuals to edit and manage files stored on a web-server. The protocol allows the creation of "web-shares" which can be used for file storage, collaborative projects, editing websites themselves, and any number of other things. WebDAV supports features like editing, copying, and moving of files, file locks, resource lists, and file property modification. Most operating systems, including MS Windows, support WebDAV directories. Install the Proper Software
- The first thing you will need (obviously) is a functioning apache2 webserver. If you happened to have install Ubuntu Server Edition with the LAMP option, then you're set. Otherwise, you'll need to get a few things with apt. Do this however you want; I will use the command line. While you're at it, you might as well get PHP to go with it.
- apt-get install apache2 php5 libapache2-mod-php5
- 3. Add Modules
- Fortunately, Apache 2.x comes with mod_dav already installed, we just have to activate it. We can do this by making some symlinks.
- cd /etc/apache2/mods-enabled
- ln -s ../mods-available/dav* .
- 4. Create LockDB file for WebDAV
- Next we need to set up a DAVLockDB file for WebDAV to use. This is a very important step, as you'll wind up with Internal Server Errors if you try to use WebDAV without it.
- mkdir /usr/share/apache2/var
- touch /usr/share/apache2/var/DAVLock
- chown -R www-data:www-data /usr/share/apache2/var
- 5. Setup Authentication and Add Users
- WebDAV can open your web server up to security risks. You don't want just anyone to wander in and change your files! There are several ways you can do authentication for your WebDAV directory, but htpasswd is the easiest and probably best for most cases. We'll make the passwords using MD5 and store them where we store the apache configurations and add an initial user while we're at it.
- htpasswd -m -c /etc/apache2/.htpasswd
- 6. You can use this command to add more users later or change their passwords. Just remember to remove the -c option or you'll truncate your password db every time! Create the WebDAV Directory
- Okay, almost done. Let's make a directory in our web document root where we will run our WebDAV. I'm calling it myWebDAV. This is the folder in which your authorized users will be able to add, delete, and modify files. The directory will need to be writable by the web server.
- mkdir /var/www/myWebDAV
- chown www-data:www-data /var/www/myWebDAV
- 7. Configure Apache
- Now all we need to tell Apache how to use WebDAV and where to enable it. This consists of adding a few definitions to the user-defined config file at /etc/apache2/httpd.conf. Open that file with an editor and add lines similar to those below.
- ## Location of the DavLock file
- DavLockDB /usr/share/apache2/var/DavLock
- ## Set up the myWebDAV directory to use WebDAV and authentication
- <Directory "/var/www/myWebDAV">
- Dav On
- AuthName "WebDAV Login"
- AuthType Basic
- AuthUserFile /etc/apache2/.htpasswd
- ## Limit access for enhanced security
- <LimitExcept GET HEAD OPTIONS POST>
- require valid-user
- </LimitExcept>
- Order allow,deny
- Allow from all
- </Directory>
- 8. Restart Apache and Test
- That's it! Restart your web server and you're good to go. You and your friends/coworkers/etc can now login and modify the files at http://your.domain.com/myWebDAV.
- /etc/init.d/apache2 restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement