Install Subversion and WebSvn on Ubuntu Server

UbuntuVersion control of your documents and code should be one of your first and major TO-DOs if you intend to develop application or website and you plan to maintain it during time with possibility to view changes made during it’s life cycle.

The first thing to do is install Subversion and apache package for Subversion. All I need to do is:

sudo aptitude install subversion libapache2-svn

In the next step I need to create a directory where my repositories will be stored. In my case /var/sourcecontrol/svn/. The default location is /var/lib/svn/.

This command will create de directory where all my repositories will be:

sudo mkdir /var/sourcecontrol/svn

After create the directory I copied my entire repository backup from windows into this directory.

Note if I need to create new repositories I just had to do:

sudo svnadmin create /var/sourcecontrol/svn/newRepository

newRepository is the name of the new repository.

Next I need to change the owner of the files in order to access using apache. This can be done with this command:

sudo chown www-data:www-data  /var/sourcecontrol/svn/repositoryName -R

repositoryName is the name of the repository.

Next I just need to configure all my repositories to be access in apache. This can be done by editing the file /etc/apache2/mods-available/dav_svn.conf

To edit I just run the command:

sudo nano /etc/apache2/mods-available/dav_svn.conf

Scroll all the way down and add the following code for each repository:

<Location /repositoryName>
  DAV svn
  SVNPath /var/sourcecontrol/svn/repositoryName
  AuthType Basic
  AuthName "Subversion repository repositoryName"
</Location>

Next restart the apache :

sudo /etc/init.d/apache2 restart

Open a browser and type http://[serverip]/repositoryName and the repository is now availably in browser.

Notice the /repositoryName in the location is the same as /repositoryName in the url.

After this step you can start doing some checkin’s 😛

The next step is to install WebSVNWebSVN is a very good web interface to see all repositories.

The first thing to do is install the package. This can be done with the command:

sudo aptitude install websvn

To have syntax highlight in the source code just install enscript . This can be done with this command:

sudo aptitude install enscript

Now a few things you should know:

During the install of WebSVN three screens will appear:
1 – Select the webserver for configuration.
2 – Specify the path of the subversion repositories, in this case (/var/sourcecontrol/svn).
3 – If all repositories are in the same parent folder leave this in blank otherwise you will have to specify all repositories separated by comma.

The package WebSVN is installed into /usr/share/websvn/, it’s necessary to copy to /var/www/. This can be done with the command:

sudo cp -r /usr/share/websvn/ /var/www/

After copy to /var/www it’s necessary to edit the file /etc/apache2/mods-available/dav_svn.conf, again with the command:

sudo nano /etc/apache2/mods-available/dav_svn.conf

Next, scroll down and add the following

<Location /websvn/>
Options FollowSymLinks
order allow,deny
allow from all
AuthType Basic
AuthName "Subversion Repository"
</Location>

Save the file and restart apache by doing:

sudo /etc/init.d/apache2 restart

Now just type http://[serverip]/websvn and you will see the WebSVN page and your repositories.

If for some reason your repositories have strange names in just edit the file /etc/websvn/svn_deb_conf.inc with the command :

sudo nano /etc/websvn/svn_deb_conf.inc

In this file you will have something like this:

<?php 
// please edit /etc/websvn/config.php 
// or use dpkg-reconfigure websvn 
$config->parentPath("/var/sourcecontrol/svn/"); 
$config->addRepository("repositoryName\", file:///var/sourcecontrol/svn/repositoryName1); 
$config->addRepository("repositoryName", "file:///var/sourcecontrol/svn/repositoryName2"); 
$config->setEnscriptPath("/usr/bin"); 
$config->setSedPath("/bin"); 
$config->useEnscript(); 
?>

Here it’s possible specify the parent path of all repositories and specify each repository name and location. it’s here also that it’s specified the path on enscript installed before.

Hope you enjoy the source control.

Leave a Reply