SVN: How to Setup SVN on Apache2 Webserver at CSLab

This is a step by step guide for setting up SVN on CSLab's webserver, colony.cs. Once its ready you can create an SVN repository accessible by non CSLab users. You could make it accessible to anyone, but I've assumed most people would like some sort of authentication setup. I found this a very useful book to get me started with SVN. Also, you can find more information about the CSLab webserver, especially the new webserver architecture that allows for user-manged webservers here.

Step 1: Creating a User-Managed Webserver
First, you'll need to log into the webserver, its called colony.cs. The makesite script will create the site.

colony:~> /opt/webserver/makesite

By default everything will be placed in /u/username/site; you can specify a different name by simply providing it as an argument to the script.

colony:~> /opt/webserver/makesite /u/username/SVN

The most critical piece of information you need to retrieve from the installation information is the given port number on which your Apache process is running. If you lose this information, you can always find it again by examining the contents of the ports.conf configuration file in your site's etc/apache2 directory. You can also look at the installation log itself at /u/username/var/log/installation.log.

You can start, stop, and manipulate your Apache servers using the following following script:

/u/username/site/bin/apache2ctl

Once started, you may access your site from the following URL:

http://www.cs.toronto.edu:portnum/

where portnum is the port number your Apache instance is running on.


Step 2: Configuring User-Managed Webserver for SVN
Copy dv_svn module to user website

colony:~> cd site/etc/apache2/mods-available/
colony:~/site/etc/apache2/mods-available> cp /etc/apache2/mods-available/dav_svn.conf .
colony:~/site/etc/apache2/mods-available> cp /etc/apache2/mods-available/dav_svn.load .

Then start the site.

colony:~/site> /u/username/site/bin/apache2ctl start

Next, the dav and dav_svn modules need to be enabled. Order matters, enable dav before enabling dav_svn and restart the server.

colony:~/site> /u/username/site/bin/a2enmod dav
Module dav installed; run /u/username/site/bin/apache2ctl restart to enable.
colony:~/site> /u/username/site/bin/apache2ctl restart
colony:~/site> /u/username/site/bin/a2enmod dav_svn
Module dav_svn installed; run /u/username/site/bin/apache2ctl restart to enable.
colony:~/site> /u/username/site/bin/apache2ctl restart


The respository needs to be stored somewhere, /var/svn seems like a good chioce.

colony:~/site> cd var/
colony:~/site/var> mkdir svn

Now, configure httpd.conf file to export/expose the svn repository by adding the following lines to httpd.conf file. The httpd.con file is located at /u/username/site/etc/apache2/.

# SVN Repository
<Location /repos>
DAV svn
SVNPath /u/vargatst/site/var/svn/repos
</Location>



Step 3: Setting up Authentication
While the goal is to make the repository accesible to non-CSLab users, it should not be accessible to just anyone who can find it. To that end, add lines to the httpd.conf file so that it now looks like this:

# SVN Repository
<Location /repos>
DAV svn
SVNPath /u/vargatst/site/var/svn/repos
AuthType Basic
AuthName "Seubversion Repository"
AuthUserFile /u/vargatst/site/etc/svn-auth-file
Require valid-user
</Location>

Now you can add user names and passwords for each person that will use the repository, in this case thee users.

colony:~/site/etc> htpasswd -cm /u/username/site/etc/svn-auth-file firstuser
New password:
Re-type new password:
Adding password for user firstuser
colony:~/site/etc> htpasswd -m /u/username/site/etc/svn-auth-file user2
New password:
Re-type new password:
Adding password for user user2
colony:~/site/etc> htpasswd -m /u/username/site/etc/svn-auth-file user3
New password:
Re-type new password:
Adding password for user user3


Step 4: Create the Repository
Finally, everything is ready for the repository. Keeping in mind that for security reasons, your CSLab home direcotry is not accessible from the webserver, first you'll need to copy the files you indent to place in the repository onto the webserver. There are serveral ways to do this, one of the simplest is to place them in your public_html directory.

apps2:~> cp Documents/example public_html/.

Now, back on the webserver, create the repository and import the file.

colony:~/site> svnadmin create /u/username/site/var/svn/repos/
colony:~/site> svn import /u/username/public_html/example file:///u/username/site/var/svn/repos/example -m"Initial import"
Adding         /u/username/public_html/example

Committed revision 1.
colony:~/site> /u/vargatst/site/bin/apache2ctl restart


Thats it, the repository is ready for users to access it using SVN.