Installing Subversion And Configuring Access Through Different Protocols On Ubuntu 11.10
Installing Subversion And Configuring Access Through Different Protocols On Ubuntu 11.10Version 1.0 Subversion (svn) is an open-source version control system (VCS), used in the development of many software projects. This tutorial shows how to install Subversion on Ubuntu 11.10 and how to configure it to allow access to a repository through different protocols: file://, http://, https://, svn://, and svn+ssh://. I do not issue any guarantee that this will work for you!
1 Preliminary NoteThis tutorial concentrates on Subversion installation and configuration, not on its usage. You can find a list of usefull svn commands here: http://wiki.greenstone.org/wiki/index.php/Useful_SVN_Commands. The complete svn documentation is here: http://svnbook.red-bean.com/en/1.5/index.html The Ubuntu 11.10 system that I use here has the IP address 192.168.0.100 which I will use in the various svn commands throughout this tutorial. Make sure you replace it with your own server's IP/hostname.
2 Installing SubversionSubversion can be installed as follows: apt-get install subversion Next we create a directory that will hold our repository/repositories - I use /var/lib/svn, but you can use another directory, if you like. mkdir -p /var/lib/svn I want to create a repository for my software project called myproject inside the /var/lib/svn directory - this can be done as follows: svnadmin create /var/lib/svn/myproject Of course, the repository is empty until we import our project into it. There are several ways or protocols that can be used to access svn:
3 Using The file:// ProtocolThe file:// protocol works out of the box (it doesn't require any server process), but only locally, not over the network. We can use it to import our software project (I have stored it in /home/falko/myproject) into our /var/lib/svn/myproject repository: svn import /home/falko/myproject file://localhost/var/lib/svn/myproject Checkouts can be done as follows: svn co file://localhost/var/lib/svn/myproject /home/falko/somedir
4 Using The http:// ProtocolFor the http:// protocol, we need to configure WebDAV on an Apache2 server. Therefore we install Apache2 and the Apache2 SVN module now: apt-get install apache2 libapache2-svn Now we configure the Apache2 SVN module by editing the file /etc/apache2/mods-available/dav_svn.conf: vi /etc/apache2/mods-available/dav_svn.conf There's a configuration already in the file, but it is commented out. You can leave it commented out, but at the end of the file, please add the following lines:
Restart Apache: /etc/init.d/apache2 restart Because we will read and write to our repositories as the Apache user (www-data) and group (www-data) from now on, we must change the owner and group of /var/lib/svn and its subdiretories to the Apache user and group now: chown -R www-data:www-data /var/lib/svn Please note: If you decide to use http:// or https:// to access SVN, do not use any of the other protocols anymore to write to SVN because the ownerships of the changed files will not match the Apache user/group if you do not use http:// or https://! Now we must create the password file /etc/apache2/dav_svn.passwd that contains all users that will have access to SVN (I will use the users falko and till here). htpasswd -c /etc/apache2/dav_svn.passwd falko Please note: Use the -c switch only if you create the /etc/apache2/dav_svn.passwd file for the first time. If you want to add another user, please leave it out (otherwise the file will be created from scratch again which means you lose all users that are already in the file): htpasswd /etc/apache2/dav_svn.passwd till You can now do a checkout as follows using the http:// protocol (please make sure you use the correct username): svn co --username falko http://192.168.0.100/svn/myproject /home/falko/somedir
5 Using The https:// ProtocolIf you want to use https://, please follow chapter 4, and then do this to enable the SSL Apache module and the default SSL web site: a2enmod ssl (Please note that the default Apache SSL web site uses a self-signed certificate. You might want to replace it with a certificate from a trusted CA. You might want to check out this tutorial for more details: How To Set Up An SSL Vhost Under Apache2 On Ubuntu 9.10/Debian Lenny.) Now you can access SVN through https:// and also http://. If you want https:// only, you can disable http:// as follows: Open /etc/apache2/mods-available/dav_svn.conf and comment out/remove the section that you have added in chapter 4: vi /etc/apache2/mods-available/dav_svn.conf
Then open the vhost configuration file /etc/apache2/sites-available/default-ssl of the default SSL vhost and add the same section between <VirtualHost> and </VirtualHost>: vi /etc/apache2/sites-available/default-ssl
Then restart Apache: /etc/init.d/apache2 restart You can do a checkout as follows using the https:// protocol: svn co --username falko https://192.168.0.100/svn/myproject /home/falko/somedir Please note: If you decide to use http:// or https:// to access SVN, do not use any of the other protocols anymore to write to SVN because the ownerships of the changed files will not match the Apache user/group if you do not use http:// or https://!
6 Using The svn:// ProtocolWe can use the svn:// protocol by starting the svnserve daemon. Before we do this, let's configure password protection for our repository. There's a conf/svnserve.conf file in each repository, so for /var/lib/svn/myproject it's /var/lib/svn/myproject/conf/svnserve.conf. open that file... vi /var/lib/svn/myproject/conf/svnserve.conf ... and uncomment the password-db = passwd line:
passwd refers to the passwd file in the same directory, i.e., /var/lib/svn/myproject/conf/passwd. Open that file and add your SVN users and passwords (passwords are in clear text): vi /var/lib/svn/myproject/conf/passwd
We can now start the svnserve daemon: svnserve -d -r /var/lib/svn/ (The -d switch makes it run as a daemon in the background.) Run netstat -tap | grep svn and you should see that snvserve is listening on port 3690 (:svn): root@server1:~# netstat -tap | grep svn Now we can use the svn:// protocol. For example, a checkout can be done as follows: svn co --username falko svn://192.168.0.100/myproject /home/falko/somedir
7 Using The svn+ssh:// ProtocolTo tunnel the svn:// protocol through SSH, just follow chapter 6 and make sure you have an SSH damon running on your Ubuntu system (if you have not, you can install it by running apt-get install openssh-server ssh ) That's it! All you have to do now is to use svn+ssh:// instead of svn://, for example, a checkout can be done as follows: svn co --username falko svn+ssh://192.168.0.100/var/lib/svn/myproject /home/falko/somedir
8 Links
|




Recent comments
9 hours 47 min ago
16 hours 28 min ago
20 hours 18 min ago
21 hours 57 min ago
1 day 6 hours ago
1 day 15 hours ago
1 day 16 hours ago
1 day 20 hours ago
2 days 37 min ago
2 days 59 min ago