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:
Edit the config file:
Change the default document root by editing server.document-root:
Where example1.com 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):
server.document-root = "/var/www/example2.com/"
Don’t forget to change example2.com 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:
Try accessing the website by using your browsers. The default location is at /var/www/example1.com/, but if you enter your website with the name example2.com you’ll be redirected to your virtual host at /var/www/example2.com/ instead (this requires a DNS).
Install and Configure Subversion
Install subversion from aptitude:
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 usermod -a -G svn user1
Where user1 is an existing user that is added to the group svn.
Set a new password for the user svn:
Create a new directory for repositories, and create a new repository for testing:
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:
Test the setting by usinf the file protocol:
This will check out our test project to /tmp/test. You should get an output like “Checked out revision 0″.
Now, assuming that you need some level of security for your code, which will be transmitted through the Internet or LAN, we have 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)
This command will list the subversion project at the location /var/svn/test of the server example.com. If you want to specify the username, just add the username and @ before the hostname as in this example:
Don’t forget to change user1, example.com, 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 nice and simple 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):
Now in the [tunnel] section add the following line:
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:
Good luck. Your comments are always appreciated.