Tuesday, July 6, 2010

Install Subversion with web access on Ubuntu Linux

Subversion control is an open source version control system. Using Subversion you can record your projects history, here you can manage your project and save change with a version number.

Installation.
To access the subversion repository from HTTP protocol, you must install and configure webserver. in this section we are using Apache2 as Server.

To install subversion run these code:

> sudo apt-get install subversion libapache2-svn



We are going to create svn repository on /home/svn

> mkdir /home/svn
> cd /home/svn
> mkdir repo


Well, let's begin to create repository here:

> svnadmin create /home/svn/repo



Will create a group name is "subversion" and replace USERNAME with actually username

> sudo addgroup subversion
> sudo usermod -a -G subversion USERNAME
> sudo usermod -a -G subversion www-data
  


Set file permissions:

> sudo chown -R www-data:subversion /home/svn/repo
> sudo chmod -R g+rws /home/svn/repo


Now, we are going to configure Vhost with svn access.. if you want to see Example subversion configuration apache2. run these code:

> sudo gedit /etc/apache2/mods-enabled/dav_svn.conf


That's an example file configuration to svn access on HTTP protocol.
in this case i want to show you how the svn repository can access per website url, you must configure it at /etc/apache2/sites-available/your_site.conf and paste code below:


  <location svn="">
     DAV svn
     SVNPath /home/svn/repos
     AuthType Basic
     AuthName "Subversion Repository"
     AuthUserFile /etc/subversion/passwd
     Require valid-user
  </location> 



Ok, a little remaining setup now!
you must create /etc/subversion/passwd file. This file contains user authentication access.
-c using for replacing existing user

> sudo htpasswd -c /etc/subversion/passwd USERNAME
> New password: 
> Re-type new password: 



Restart your server:

> sudo /etc/init.d/apache2 restart


If you are uncertain whether the passwd file exists, you can check this with run this command:

> cat /etc/subversion/passwd



Now, to access the repository you can run the following command:

> svn co http://hostname/svn/repo myproject --username user_name

No comments:

Post a Comment