|
OSXFAQ Mac OS X Tip-of-the-Day 
Set up a WebDAV Server - Configure Apache
By Adrian Mayo - Editor - OSXFAQ
To configure apache is to edit its configuration file in
/etc/httpd/httpd.conf. If you have BBedit you might be able to use
that. Otherwise fire up the Terminal in Applications:Utilities. All
changes must be made as the root user because of the permissions on
httpf.conf.
In the terminal do this (and note that the '$' at the start of each
line represents the prompt, so don't type it, just what follows).
Gain root permissions with:
$ sudo -s
password: type-your-admin-password-here
This gives you root permissions for everything you now type, so be
careful. If you are not comfortable with such power, then instead
precede each command I give with 'sudo' so that root permissions apply
only to the command that follows.
First we must create a directory (folder) which will be the 'home'
folder of WebDAV, and also a folder where WebDAV can do some
housekeeping.
Move to the folder above Apache's document root. Type:
$ cd /Library/WebServer/
Next, make a housekeeping folder called 'DavLock' and
set it to be owned by user 'www', which is the user Apache runs as:
$ mkdir DavLock
$ chown www:www DavLock/
The next three commands move into Apache's document root and create and
own WebDav - the home folder of the WebDAV server.
$ cd Documents/
$ mkdir WebDav
$ chown www:www WebDav/
You are free to use different folder names, but you must be consistent
throughout all the following instructions.
If you have changed Apache's Document root, then change the above
commands to create WebDav in the document root, and DavLock anywhere
outside of the document root (/var/webdav/DavLock for example).
Next we configure Apache.
Move to the Directory containing the Apache configuration file:
$ cd /etc/httpd
Save the original file:
$ cp httpd.conf httpd.conf.mysaved
Edit the file with 'Pico'. RETURN means to hit the return key.
$ pico httpd.conf
Now type Control-W dav RETURN to search for 'dav'. You will probably
end up on a line like this:
#LoadModule dav_module libexec/httpd/libdav.so
Delete the # character leaving:
LoadModule dav_module libexec/httpd/libdav.so
The # is a comment and tells Apache to ignore the line. We have
removed the comment, which means Apache will now load the WebDAV
module. WebDAV is not enabled by default; but it is now - or almost.
Search for 'dav' again and remove the comment so you have a line that
reads:
AddModule mod_dav.c
Now the WebDAV is enabled, we need to configure it. Search for
WebServer until you get to the line:
DocumentRoot "/Library/WebServer/Documents"
Just before this line (or after - see the screen shot
later) add the following:
# Enable WebDav server
#
DavLockDB /Library/WebServer/DavLock/lock
Dav on
Options Indexes
Order Allow,Deny
Allow from 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
# allow external access (Wednesday's tip here)
# limit access by command type (Friday's tip)
'DavLockDB' tells Apache of the location of the housekeeping folder we
created previously.
The '' command defines the home folder of WebDAV
within Apache's document root.
'Dav on' enables WebDAV for this location
'Order' and 'Allow' stop any access from IP addresses not listed. I
have listed the local host and all possible private networks. Your
WebDAV server is accessible from the local machine and anyone on your
LAN, but not from the Internet.
Finally, hit:
Control-O RETURN
Control-X
to quit Pico.
Restart Apache, either by Stop/Starting it in System Preferences, or by
issuing the commands:
$ apachectl configtest
$ apachectl graceful
If the configtest fails, check your edits to httpd.conf
We like screen shots, so here's a pointless one:
To test the server, launch iCal and select a calendar (one of your own,
not one your are subscribing to). Select menu Calendar -> Publish... .
Follow the screen shot below to publish the your server.
The address is http://127.0.0.1/WebDav, which you can also type into
your browser. You should see a directory listing including the .ics
file published by iCal.
Note that the WebDav setup so far does not have any authentication -
anyone can login and dump files on your machine. The 'Allow' clauses
thus restrict access to local networks only. Wednesday's tip shows how
to add authentication, allowing you to open up the server to the
Internet.
Enjoy !! :-)
Panther 10.3.6
To discuss this tip in the OSXFAQ Mac OS X Tip-of-the-Day Forum, click here:
http://forums.osxfaq.com/viewforum.php?f=100
E-mail your comments or suggestions to webmaster@osxfaq.com
|