Thursday, 5 December 2013

Step by Step Installation of SVN (Subversion) Server


Subversion is free open source version control system to manage the files/directories and the changes of them made all time. The open source community has been using Subversion (SVN) widely of many collaborative development projects.
SVN supports several protocols for network access: SVN, SVN+SSH, HTTP, HTTPS. If you are behind a firewall, HTTP-based Subversion is advantageous since SVN traffic will go through the firewall without any additional firewall rule setting. In this tutorial, I will describe how to set up an HTTP-based Subversion server on Cent OS 5.8.

1.       Installation of Apache Server.

[root@svnserver ~]# yum install httpd*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: centos.mirror.net.in
 * base: mirror.vietoss.com
 * centosplus: mirrors.fibo.vn
 * contrib: mirrors.digipower.vn
 * extras: centos-hn.viettelidc.com.vn
 * updates: mirrors.digipower.vn
Setting up Install Process
Package httpd-2.2.3-83.el5.centos.x86_64 already installed and latest version

[root@svnserver ~]# /etc/init.d/httpd status
httpd is stopped
[root@svnserver ~]# chkconfig httpd on
[root@svnserver ~]# service httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for svnserver
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]

[root@svnserver ~]# vi /etc/httpd/conf/httpd.conf
ServerName svnserver.example.com

[root@svnserver ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

2.       Installation of subversion server.
[root@svnserver ~]# yum install mod_dav_svn subversion

3.       Configure Subversion.

Open the subversion config file ‘/etc/httpd/conf.d/subversion.conf’ and edit as follows:

[root@svnserver conf.d]# vi /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, "/var/www/svn".  Each repository
# must be readable and writable by the 'apache' user.  Note that if
# SELinux is enabled, the repositories must be labelled with a context
# which httpd can write to; this will happen by default for
# directories created in /var/www.  Use "restorecon -R /var/www/svn"
# to label the repositories if upgrading from a previous release.
#

#
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
#   # cd /var/www/svn
#   # svnadmin create stuff
#   # chown -R apache.apache stuff
#

<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn

   # Limit write permission to list of valid users.
      # Require SSL connection for password protection.
      # SSLRequireSSL
      AuthType Basic
      AuthName "Authorization Realm"
      AuthUserFile /etc/svn-auth-users
     Require valid-user
   </Location>

4.       Create a new user for Subversion called “jitendra” for instance.

[root@svnserver ~]# htpasswd -cm /etc/svn-auth-users jitendra
New password:
Re-type new password:
Adding password for user Jitendra

5.       Create and configure subversion Repository.

Create a directory for subversion repository under “/var/www/svn” directory.

[root@svnserver ~]# mkdir /var/www/svn
[root@svnserver ~]# cd /var/www/svn
[root@svnserver svn]# svnadmin create repos
[root@svnserver svn]# ls
repos
 [root@svnserver svn]# chown apache.apache -R repos
[root@svnserver svn]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

6.       Disable Anonymous Users.

If you want to disable the anonymous user to access the repository, just edit the following line in‘repos/conf/svnserver.conf’ file.

[root@svnserver conf.d]# vi /var/www/svn/repos/conf/svnserve.conf

anon-access = none
authz-db = authz

7.       SELINUX Settings.

 If you enabled SELinux, run the following commands to change the SELinux context security.

[root@svnserver ~]# chcon -R -t httpd_sys_content_t var/www/svn/repos/
[root@svnserver ~]# chcon -R -t httpd_sys_rw_content_t /var/www/svn/repos/

8.       IPTABLES Settings.

Make sure that you have opened the apache default port ’80 through iptables.
[root@svnserver ~]# vi /etc/sysconfig/iptables
-A INPUT -p udp -m state --state NEW --dport 80 -j ACCEPT

-A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT

9.       Testing Subversion.

We can test the subversion by typing http://10.226.10.10/svn/repos in web browser.






10.   Create additional links(directories) under Subversion Repository.

Create some sample directories in any place and import them to your Subversion repository.

[root@svnserver ~]# mkdir subversion-templates
[root@svnserver ~]# cd subversion-templates/
[root@svnserver subversion-templates]#mkdir  jitendra

Now import the sub directories using the command ‘svn import’.
[root@svnserver ~]# svn import -m 'Initial import' subversion-templates/ http://10.226.10.10/svn/repos/
Authentication realm: <http://10.226.10.10:80> Subversion repositories
Username: jitendra
Password for 'jitendra':
Adding         /subversion-templates/jitendra

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <http://10.226.10.10:80> Subversion repositories
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
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? no

Committed revision 1.


No comments:

Post a Comment