Linux Pathfinder: Linux Howtos and Tutorials

Install SVN on Ubuntu 12.04

Install SVN on Ubuntu 12.04
Install SVN on Ubuntu 12.04

Subversion another name we known as SVN, is an open source version control system. SVN is a really easy to use Revision control/version control/source control and store changes of your project files such as coding and documentation.

In this tutorial we will discuss how to install subversion on Ubuntu 12.04.

Install SVN on Ubuntu

First we will install and configure Apache2
Second we will install and configure SVN
After that we will test SVN service

Apache Webserver must be installed and configured before installing SVN.

Open terminal with press ALT + CTR + T.

Install and Configure Apache

:: See below command to install apache2.

asifark@linuxpathfinder:~$ sudo apt-get install apache2

:: Open this file /etc/apache2/httpd.conf after installation and add (ServerName localhost) to avoid warning during apache service restart.

:: Restart the apache service.

asifark@linuxpathfinder:~$ sudo /etc/init.d/apache2 restart

:: Open http://serveripaddress in your browser ( Eg: http://192.168.195.129 ), you will get the page as follows.

Apache It Works
Apache It Works

Install SVN on ubuntu 12.04

Install and configure SVN.

:: Follow the below mentioned command to install SVN packages.

asifark@linuxpathfinder:~$ sudo apt-get install subversion libapache2-svn

:: When installation completed, start creating the repositories. Below we are creating folder structure like /svn/repositoryname.

asifark@linuxpathfinder:~$ mkdir /svn

:: Create a repository testrepo using as follows.

asifark@linuxpathfinder:~$ sudo svnadmin create /svn/testrepo

:: Permission modification for the repository.

asifark@linuxpathfinder:~$ sudo chown -R www-data:www-data /svn/testrepo

:: To store user authentication details, create a file as shown below (/etc/subversion/reponame.users).

 asifark@linuxpathfinder:~$ sudo htpasswd -c /etc/subversion/testrepo.users asiface
 New password:
 Re-type new password:
 Adding password for user asiface

Here testrepo.users is the filename and asiface is the username for accessing repository.

Note: for additional users have to omit -c onwards.

:: Create /etc/apache2/conf.d/svn.conf file and add the below lines.

<location /repos>
 DAV svn
 # SVN path
 SVNParentPath /svn/
 AuthType Basic
 AuthName "Authorization Realm"
 #password file path
 AuthUserFile /etc/subversion/testrepo.users
 Require valid-user
 </location>

:: Restart apache service now.

asifark@linuxpathfinder:~$ sudo /etc/init.d/apache2 restart

Now you have successfully installed and configured SVN server on ubuntu 12.04.

Testing

:: For a quick testing, you can access http://{serverip}/repos/reponame in your browser ( Eg http://192.168.195.129/repos/testrepo ) and after successful authentication you will see the page as follows.

:: Perform checkout and commit using command line.

Create a folder to checkout

asifark@linuxpathfinder:~$ mkdir svntestrepo

Checkout new copy to svntestrepo folder using the below command.

 asifark@linuxpathfinder:~$ svn co http://asifark@192.168.195.129/repos/testrepo svntestrepo
 Authentication realm: <http://192.168.195.129:80> Authorization Realm
 Password for 'asifark':
 Authentication realm: <http://192.168.195.129:80> Authorization Realm
 Username: asiface
 Password for 'asiface':
 -----------------------------------------------------------------------
 ATTENTION!  Your password for authentication realm:
 <http://192.168.195.129:80> Authorization Realm
 can only be stored to disk unencrypted!  You are advised to configure
 your system so that Subversion can store passwords encrypted, if
 possible.  See the documentation for details.
 You can avoid future appearances of this warning by setting the value
 of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
 '/home/asiface/.subversion/servers'.
 -----------------------------------------------------------------------
 Store password unencrypted (yes/no)? yes
 Checked out revision 0.

Now create some files.

 asifark@linuxpathfinder:~$ cd svntestrepo/
 asifark@linuxpathfinder:~/svntestrepo$ touch test1.txt
 asifark@linuxpathfinder:~/svntestrepo$ touch test2.txt

Before go for commit, we will add the files.

 asifark@linuxpathfinder:~/svntestrepo$ svn add test1.txt test2.txt
 A test1.txt
 A test2.txt

Now we will commit the added files. You can add any log message which you are going to do in svn and close the editor.

 asifark@linuxpathfinder:~/svntestrepo$ svn commit
 Adding test1.txt
 Adding test2.txt
 Transmitting file data ..
 Committed revision 1.

Create one more file for testing.

 asifark@linuxpathfinder:~/svntestrepo$ touch test3.txt

Repeat the steps as above.

 asifark@linuxpathfinder:~/svntestrepo$ svn add test3.txt
 A test3.txt

Now again commit the added file.

 asifark@linuxpathfinder:~/svntestrepo$ svn commit
 Adding test3.txt
 Transmitting file data ..
 Committed revision 2.

In the browser open your repository, you will see the recently committed files.

Suggest to use or you can use svn clients such as Tortoisesvn for windows and Rapidsvn for ubuntu.

Share this article:

Asif Khan's picture
I am an experienced Linux System and Network Administrator with having more than 10 years of experience. My primary responsibilities are to keep up and running Linux system environment, backups important data with scripting and configuration management on AWS Linux server environments. My aim is to help people, in finding their path towards a solution to their problems. Well, I believe helping others can good for both parties, to them and to you as well. That day and today is the day that thousands of people seek help from my website to help people find answers to their questions. I am sure that everyone will get all the answers to their questions related to software and operating system, and this website will help you keep your system updated.

Add new comment

Image CAPTCHA

Enter the characters shown in the image.