To access the repository via Apache, the Mac's built-in web server, I need to make a few changes to the Apache config file and to the repository's permissions.
At the prompt, I change to the configuration directory for Apache and back up my httpd.conf file, which is where the Apache configuration settings are kept:
Voltage:~ voltmer$ cd /etc/apache2/ Voltage:apache2 voltmer$ sudo cp httpd.conf httpd.conf.bak
Now I edit the file using the nano editor, which uses the Control key with letters to issue commands that are listed across the bottom of the screen. (You can use any text editor to edit the file.) Here is the command to start nano as superuser (see Figure 3):
Voltage:apache2 voltmer$ sudo nano httpd.conf

Figure 3. Edit the httpd.conf file as superuser.
I must edit the file to load the WebDAV SVN module and
configure the directory for the repository. Within the file there are several
lines starting with LoadModule. At the end of that
section I add the following on a line by itself (see Figure 4):
LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so

Figure 4. Add a line to load the DAV SVN module.
Now I scroll down to the end of the file and add the following section (see Figure 5):
<Location /repo> DAV svn SVNPath /usr/local/svn/repo AuthType Basic AuthName "Subversion" AuthUserFile /usr/local/svn/svn_passwd Require valid-user </Location>

Figure 5. Add a section to configure the repository.
This tells Apache to map the /repo web directory to the actual file system location of the repository. This links the following URL:
http://localhost/repo
to the repository at /usr/local/svn/repo.
To save the file and exit nano I press Control (^X).
Because I don't want unauthorized users reviewing my
repository I am going to create a password file to protect the contents. This
file, /usr/local/svn/svn_passwd, was specified in the httpd.conf file but it does not yet exist. To create it, I
change directory to the location where I am going to keep my repository and run
the htpasswd utility to make the file (see Figure 6):
Voltage:apache2 voltmer$ cd /usr/local/svn Voltage:svn voltmer$ sudo htpasswd -c svn_passwd voltmer New password: Re-type new password: Adding password for user voltmer

Figure 6. Run htpasswd to add a password to the repository.
It prompted me twice for the password for the user known as voltmer. It is not asking for my current user password but a new one for the web SVN access. You can, however, use the same password if you want. I also have to make sure that only the web server can read the repository, so I execute the following commands to set the permissions on the repository and password file (see Figure 7):
Voltage:svn voltmer$ cd /usr/local Voltage:local voltmer$ sudo chown –R www:www /usr/local/svn Voltage:local voltmer$ sudo chmod 600 /usr/local/svn/svn_passwd Voltage:local voltmer$ ls -la /usr/local/svn/svn_passwd -rw------- 1 _www _www 22 Sep 2 16:23 svn_passwd

Figure 7. Set permissions to restrict access to the repository and password file.
The final task is to start (or restart) the web server. On a Mac, open System Preferences and then go to the Sharing control panel. If Web Sharing is not already checked (see Figure 8), then select it (see Figure 9).
Figure 8. If Web Sharing is not enabled, select it.
Figure 9. Web Sharing is now selected and Apache is started.
If it is already checked (Apache is running), then deselect and reselect the Web Sharing option to stop Apache and restart it. To verify that everything is working correctly, point your web browser (for example, Safari) to http://localhost/repo. If all is working, you will be prompted for the username and password that you just created (see Figure 10), then you will see the root directory of the repository.

Figure 10. Enter your username and password to access the repository.
If you see the text "Powered by Subversion version…" (see Figure 11), then you know the setup is working.

Figure 11. "Powered by Subversion…" confirms that Apache is configured for SVN.