Saturday, May 10, 2014

Install SVN (Subversion) Server on CentOS

Install SVN (Subversion) Server on CentOS

Subversion is a free open source version control system. It is used by developers to maintain current and historical versions of files such as source code, web pages, and documentation etc. Subversion is used to manage and recover files/directories and the changes of them made all time.
Before start SVN setup, need to update yum repositories and packages as shown below:
[root@linuxpathfinder /]# yum update
Before installing SVN packages, you must install and configure apache Webserver. My server IP address is 192.168.227.128

Install and Configure Apache (httpd)


To install apache along with dependencies, type following command.
[root@linuxpathfinder /]# yum install httpd
After that, open apache configuration file /etc/httpd/conf/httpd.conf
Find “#ServerName www.example.com:80″
#ServerName www.example.com:80
and add this line below. “ServerName server-ip-address:80″
#ServerName www.example.com:80
ServerName 192.168.227.128
Start the apache (httpd) service.
[root@linuxpathfinder /]# service httpd start
to start apache service automatically while booting, type below command in CLI.
[root@linuxpathfinder /]# chkconfig –levels 235 httpd on
Now open your server ip address in the browser.
install-subversion-01
If apache web page is unable to open, disable the firewall (iptables) and selinux service on your server .
Iptables
[root@linuxpathfinder /]# service iptables stop
[root@linuxpathfinder /]# chkconfig iptables off
Selinux
open the file /etc/selinux/config and find the line
SELINUX=enforcing
and replace with
SELINUX=disabled
web page is able to open after reboot the server.

Install and Configure SVN Server


Type following command to start installing svn packages.
[root@linuxpathfinder /]# yum install subversion mod_dav_svn
Configure Subversion
Open the subversion config file ‘/etc/httpd/conf.d/subversion.conf’ and edit as follows.
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
##Add the following lines ##

DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “Subversion repositories”
AuthUserFile /etc/svn-auth-users
Require valid-user

#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, “/var/www/svn”.  Each repository
# must be both:
#
#   a) readable and writable by the ‘apache’ user, and
#
#   b) labelled with the ‘httpd_sys_content_t’ context if using
#   SELinux
# Add SVN (Subversion) users
Use following command:
## Create ark1 ##
htpasswd -cm /etc/svn-auth-users ark1
New password:
Re-type new password:
Adding password for user ark1
## Create ark2 ##
htpasswd -m /etc/svn-auth-users ark2
New password:
Re-type new password:
Adding password for user ark2
Note: Use exactly same file and path name (/etc/svn-auth-users) as used on subversion.conf file.

Create and Configure SVN Repository


[root@linuxpathfinder /]# mkdir /var/www/svn
[root@linuxpathfinder /]# cd /var/www/svn
Create a new repository and give permissions in the svn by issuing the below commands.
[root@linuxpathfinder svn]# svnadmin create newrepo
[root@linuxpathfinder svn]# chown -R apache.apache newrepo
Restart Apache:
# Fedora #
systemctl restart httpd.service
#OR#
service httpd restart
#CentOS / RHEL#
/etc/init.d/httpd restart
#OR#
service httpd restart
Goto http://192.168.227.128/svn/newrepo address and you should see something as shown below, write username and password:
install-subversion-02
SVN testrepo revision 0:
install-subversion-03
Configure repository
To disable anonymous access and enable access control add following rows to newrepo/conf/svnserve.conf file:
## Disable anonymous access ##
anon-access = none
## Enable access control ##
authz-db = authz

Create trunk, branches and tags structure


Create “template” directories with following command:
[root@linuxpathfinder /]# mkdir -p /tmp/subversion-template/{trunk,branches,tags}
Then import template to project repository using “svn import” command:
[root@linuxpathfinder /]# svn import -m ‘Initial import’ /tmp/subversion-template/ http://192.168.227.128/svn/newrepo/
Authentication realm: Subversion repositories
Password for ‘root’:
Authentication realm: Subversion repositories
Username: ark1
Password for ‘ark1′:
Adding         /tmp/subversion-template/trunk
Adding         /tmp/subversion-template/branches
Adding         /tmp/subversion-template/tags
———————————————————————–
ATTENTION!  Your password for authentication realm:
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)? yes
Committed revision 1.
Check results on browser and see testrepo revision 1:
install-subversion-04
Now your newly created directory structure will be listed under your main repository. Hope this tutorial helpful for you.

No comments:

Post a Comment