Tuesday, December 27, 2011

Configuration of SVN over http in Linux

Prerequisite:
                   1- Apache Server 2.0 or later.
                   2- finch dependency
                   3- libpurple dependency
                   4- apr and apr-util dependency

Installation of SVN :

• In terminal execute:
   [root@upload /]# yum install mod_dav_svn subversion
• It will resolve the dependency for SVN and then installed the distribution according to the default configuration.
• If you don't have Apache installed already, it'll go ahead and drag that down as well.

Configuration of Apache Server :

• First we need to check that apache is working fine or not...
   [root@upload /]# service httpd start
   [root@upload /]# chkconfig httpd on
• Check the server is on or not by entering the url
• http://localhost

Sub Versions Apache Configuration :

Next step to configure svn for apache.

• Navigate to directory of httpd config
  [root@upload /]# cd /etc/httpd/conf.d/
• Open the subversion.conf file in editor mode
  [root@upload /]# vim subversion.conf
• Make sure you uncomment the following if they are commented out
   LoadModule dav_svn_module modules/mod_dav_svn.so 
   LoadModule authz_svn_module modules/mod_authz_svn.so
• Add the following to allow a basic authentication and point Apache to where the actual repository resides.

<Location /repos>
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName "Subversion repos"
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>

• The location is what Apache will pass in the URL bar. For instance: http://localhost/repos points to the SVNPath that you have specified.

User and Password Configuration:

Next we have to actually create the password file that you specifie previous step. Initially you'll use the -cm arguments. This creates the file and also encrypts the password with MD5. If you need to add users make sure simply use the -m flag, and not the -c after the initial creation.

[root@upload /]# htpasswd -cm /etc/svn-auth-conf
username1
New password:
Re-type new password:
Adding password for user username1

[root@upload /]# htpasswd -m /etc/svn-auth-conf
username2
New password:
Re-type new password:
Adding password for user username2

Configure your Repository :

Next thing you need to do is to create the actual repository from which you will check in and out your files.

[root@upload /]# cd /var/www/
[root@upload /]# mkdir svn
[root@upload /]# cd svn
[root@upload /]# svnadmin create repos
[root@upload /]# chown -R apache.apache repos
[root@upload /]# service httpd restart

• Check access your repository from a web browser: http://localhost/ repos. You should get a popup box asking for a username and password.Put the username password username1 and password for that.
• Now you can access your repository from http://.

CheckOut :

 [root@upload /]# svn checkout http://localhost/repos
 Authentication realm: <http://localhost:80> Subversion repos
 Password for 'root': [Ex-root]
 Authentication realm: <http://localhost:80> Subversion repos
 Username: username1
 Password for 'user': [Ex-username1]
 Checked out revision 0.


Feel free to ask if you have any query.

Thank You

2 comments:

  1. Great to see such a rare post. I successfully configured SVN over apache. Now I can browse my repository on web and can add hyperlinks into web pages or my defect tracking system to navigate to the source file directly.

    Can you provide the same for windows too...

    Thanks in advance.

    ReplyDelete
  2. Thanks a lot.

    It really very useful.
    It saved my lots of time.

    ReplyDelete