This article is a step-by-step guide for installing Lighttpd (pronounced lighty) and Subversion on Debian Lenny. My previous setup was Subversion with Apache, however Apache was too heavy for my virtual private server so I had to move to Lighttpd. Most resources from the previous article are used in this article as well.

Sadly, however, there is no mod_svn for Lighttpd, and it will not be implemented in the near future. This is one of the good reasons why not.

The most common solution is to use mod_proxy and forward the command to Apache with the module dav_svn, but it doesn’t make sense to run Apache in parallel with Lighttpd if we tried to avoid using Apache since the beginning.

My solution was to use svnserve, which is the default server for svn and has a relatively better performance than WebDAV on Apache. The operations of lighttpd and svnserve are totally decoupled, which means we do not need to configure Lighttpd for svnserve and vice versa.

If you prefer using Apache than svnserve, as many people did, use this very simple guide.

Otherwise, please follow the following steps:
Install and Configure Lighttpd

Install the package from aptitude:
sudo aptitude install lighttpd

Edit the config file:
sudo vi /etc/lighttpd/lighttpd.conf

Change the default document root by editing server.document-root:
server.document-root = “/var/www/”

Where is the directory where you default website is located.

If you need to create a virtual host, add the following virtual host at the end of the file (otherwise skip this step):
$HTTP[“host”] == “(^|\.)example2\.com” {
server.document-root = “/var/www/”

Don’t forget to change to your own directory.

Noted that Lighttpd has a module called simple-vhost, however, it’s not the robust choice and I don’t recommend it.

Now save the file and reload Lightty by:
sudo /etc/init.d/lighttpd force-reload

Try accessing the website by using your browsers. The default location is at /var/www/, but if you enter your website with the name you’ll be redirected to your virtual host at /var/www/ instead (this requires a DNS).
Install and Configure Subversion

Install subversion from aptitude:
sudo aptitude install subversion

A new subversion user group should be created. this can be done by creating a new user called svn and and the existing users to this group, as follows:
sudo useradd svn
sudo usermod -G svn user1

Where user1 is an existing user that is added to the group svn.

Set a new password for the user svn:
sudo passwd svn

Create a new directory for repositories, and create a new repository for testing:
sudo mkdir /var/svn
sudo svnadmin create /var/svn/test
sudo chown -R svn:svn /var/svn

This will create a new directory called /var/svn which contains a new testing repository test.

Don’t forget to change the permission for all users in the group svn for the test project:
sudo chmod -R g+w /var/svn/test

Test the setting by usinf the file protocol:
svn co file:///var/svn/test /tmp/test

This will check out our test project to /tmp/test. You should get an output like “Checked out revision 0”.
Using svnserve

Now, assuming that you need some level of security for your code which will be transmitted through the Internet or LAN, we need to enable ssh tunneling for svnserve. The good news is that you can use the protocol svn+ssh, by default. This will make a ssh connection to you server, run svnserver, and stop svnserver after the command is executed. This is an example:

(on the client side)
svn list svn+ssh://

This command will list the subversion project at the location /var/svn/test of the server If you want to specify the username, just add the username and @ before the hostname as in this example:
svn list svn+ssh://

Don’t forget to change user1,, and /var/svn/test to your own setting.

If SSH key authentication was not set, you will be asked for your password twice. If you feel annoyed by this strange design, set the public key authentication up. If you don’t know how to do it, I found this a simple and quick guide for beginners.
Other port than 22?

If, for a security reason, your ssh server doesn’t run on port 22, you need to edit /etc/subvesion/config in the client side (assuming you client also uses Debian Lenny):
sudo vi /etc/subversion/config

Now in the [tunnel] section add the following line:
ssh2222 = $SVN_SSH_2222 ssh -p 2222 -o ControlMaster=no

This will use ssh tunneling on port 2222 instead of the default port 22. You can change the port to you own setting and also change ssh2222 and SVN_SSH_2222 to the name you prefer. ControlMaster option must be turned off, according to the default configuration file.

On the client side you can list the repository by using the command:
svn list svn+ssh2222://

Good luck.