How To Install And Use SVN With Apache dav_svn On Ubuntu 14.04
Submitted by howtoforge (Contact Author) (Forums) on Sat, 2014-07-19 10:12. :: Linux | Ubuntu | Apache
How to Install and Use SVN with apache dav_svn on Ubuntu 14.04
1.1 SVN-An OverviewSubversion is a popular open source version control system that enables users to record the history of source files and documents, and manage files and directories over a period of time. It is akin to a tree of files being placed into a central repository on the lines of a regular file server, barring that each modification made to these files and directories is always remembered.
1.2 Step-by-Step Guide on the Installation and Use of SVN on Ubuntu 14.04This tutorial explains the process of installing and using SVN on Ubuntu 14.04 as per steps outlined below.
1.2.1 Step 1: Ensuring Up-to-Date Installed PackagesAt the outset, you must ensure that all the packages installed on your system are updated. The following command shall help you do that:
sudo apt-get update
1.2.2 Step 2: Downloading the Subversion, Subversion Tools and Libapache2 packagesTo run a Subversion (SVN) server, you need all the requisite packages, and you need to key in the following command for the same:
sudo apt-get install subversion subversion-tools libapache2-svnYou are now geared up to for the next step.
1.2.3 Step 3: Creating Subversion (SVN) DirectoryHere, you are required to create a directory where all the repositories may be housed. It is advisable to choose a directory that is easily accessible to your the managed backup service for obvious reasons. Please key in the following command to do the same:
sudo mkdir /home/svnThis brings you to the end of this step, and you may move on to the next one, as explained below.
1.2.4 Step 4: Creating a Test RepositoryAs part of this step, users need to first create a new folder to create the test project, and subsequently create a repository for the same. The following command shall help you do that:
sudo mkdir ~/test
1.2.5 Step 5: Adding Files into the Test ProjectOnce you have created the repository, please use the following command to add files into the test project:
sudo svn import ~/test file:///home/svn/test -m 'Initial project directories'The above command lets you add and also commit the new directories into the repository, all in one go. Further, for Apache to access the SVN repositories, the directory thus created (/home/svn directory) must necessarily be owned by the same user and also group that Apache runs as. More often than not, in Ubuntu, it happens to be www-data. In order to change the directory owner, please use the following command:
sudo chown -R www-data:www-data /home/svnThe above command shall enable you to change the owner of the directory, and you may subsequently move on to the next step.
1.2.6 Step 6: Configuration of ApacheUsing the following command, you would be able to enable the dav_svn Apache module:
sudo a2enmod dav_svnAfter having enabled this, you would be required to modify the Apache configuration file (as follows):
sudo nano /etc/apache2/apache2.confRight at the bottom of the file, please add the following lines, before saving the file by hitting Ctrl+X.
After having saved this, you must restart the Apache service so as to implement the changes, by using the following command:
sudo service apache2 restartMoving on, you would now be in a position to browse through the test repository you created by opening the web browser in Firefox, and visiting the following link:
Here, you would be able to view all the three directories, though they would all be empty. You may now proceed to the next step.
1.2.7 Step 7: Securing the SVN RepositoriesBefore the users start committing the files to the test repository, they must ensure that only authorized users are able to view it. The current settings, however, would allow unauthorized viewing, and checking out of the repository and its contents, in addition to checkout and committing of files by just about anyone. To secure the repositories, you must supply a username and a password before you begin to view the repository/ perform any action on the same. To execute this, you must reopen apache2.conf, and replace the SVN Location information with the following:
Further, you must create a password file by using the following command:
htpasswd -cm /etc/svn-auth disneyUpon keying in the above command, you would be prompted to enter and confirm your password, and subsequently your details would be saved. Next, the Apache service must be restarted, and subsequently, the user would need to authenticate themselves before going about viewing the repositories.
1.2.8 Step 8: Checking Out the Repository and Committing FilesFor checking out the files contained within the repository into a new directory (let us call it Test2) within the home directory, you first need to create the new directory before you may issue the checkout command (as explained below):
svn add index.php