This tutorial explains how to setup and use an SVN repository server on centOS. Before I start, let me explain what actually SVN represents and what it is used for. SVN is actually an abbreviation of SubVersion which had been created by the Apache software developer. It enables you to create and maintain your own repository and gives fine-grained access rights to a dedicated user.
It is very effective for controlling the versioning of files, documents or folders. It is very useful for any group orteam that intends to start their own software projects.
1. Preliminary NoteFor this tutorial, I am using CentOS 6.4 in the 32bit version. The end result will show you how a dedicated client canmanage to access the SVN repository using any kind of operating system platform.
2. Installation PhaseTo start with a fresh SVN server, we need to install certain packages. The packages related are apache httpd, mod_dav_svn and subversion. The HTTPD package is needed as a web server service for this process.
As this tutorial uses the CentOS operating system, we'll take the packages from the yum repository. You may use other packageslike nginx, lighttpd or any familiar web server service to replace httpd if you like. Below are the steps:
ifconfig
[[emailprotected] ~]# ifconfigeth0 Link encap:Ethernet HWaddr 08:00:27:61:E4:88
inet addr:192.168.43.101 Bcast:192.168.43.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe61:e488/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4640 errors:0 dropped:0 overruns:0 frame:0
TX packets:6845 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:444461 (434.0 KiB) TX bytes:549473 (536.5 KiB) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2125 errors:0 dropped:0 overruns:0 frame:0
TX packets:2125 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:186888 (182.5 KiB) TX bytes:186888 (182.5 KiB)
yum install -y httpd
[[emailprotected] ~]# yum install -y httpdLoaded plugins: refresh-packagekit, security
Repository 'OEL64' is missing name in configuration, using id
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i686 0:2.2.15-26.0.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================Package Arch Version Repository Size
==============================================================================================================
Installing:
httpd i686 2.2.15-26.0.1.el6 OEL64 825 k Transaction Summary
==============================================================================================================
Install 1 Package(s) Total download size: 825 k
Installed size: 2.8 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : httpd-2.2.15-26.0.1.el6.i686 1/1
Verifying : httpd-2.2.15-26.0.1.el6.i686 1/1 Installed:
httpd.i686 0:2.2.15-26.0.1.el6
Complete!
yum install -y subversion
[[emailprotected] ~]# yum install -y subversionLoaded plugins: refresh-packagekit, security
Repository 'OEL64' is missing name in configuration, using id
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package subversion.i686 0:1.6.11-7.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================Package Arch Version Repository Size
==============================================================================================================
Installing:
subversion i686 1.6.11-7.el6 OEL64 2.2 M Transaction Summary
==============================================================================================================
Install 1 Package(s) Total download size: 2.2 M
Installed size: 11 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : subversion-1.6.11-7.el6.i686 1/1
Verifying : subversion-1.6.11-7.el6.i686 1/1 Installed:
subversion.i686 0:1.6.11-7.el6
Complete!
yum install -y mod_dav_svn
[[emailprotected] ~]# yum install -y mod_dav_svnLoaded plugins: refresh-packagekit, security
Repository 'OEL64' is missing name in configuration, using id
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mod_dav_svn.i686 0:1.6.11-7.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================Package Arch Version Repository Size
==============================================================================================================
Installing:
mod_dav_svn i686 1.6.11-7.el6 OEL64 79 k Transaction Summary
==============================================================================================================
Install 1 Package(s) Total download size: 79 k
Installed size: 161 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mod_dav_svn-1.6.11-7.el6.i686 1/1
Verifying : mod_dav_svn-1.6.11-7.el6.i686 1/1 Installed:
mod_dav_svn.i686 0:1.6.11-7.el6
Complete!
3. Configuration PhaseGreat, now the installation part is done. Next, we'll move forward on the configuration part. First, let's create a dedicated directory for SVN repository usage. This is an optional process but it's a good practice when implementing for a larger scale group. Below are the steps:
mkdir /data/svn
Now we will create our first repository directory, I will name it repo1 . As a client shall be able to access the repository via browser or SVN client tools later, we will grant the ownership for the directory to apache as it is the owner of the web server service. Below are the steps:
svnadmin create /data/svn/repo1chown -R apache:apache /data/svn/repo1
Once done, you'll notice that several related folder and files will be created by default under our new repository directory.
cd /data/svn/repo1ls [[emailprotected] repo1]# ls
conf db format hooks locks README.txt
Now we edit the configuration file to meet our requirements. First, we will edit the configuration file svnserver.conf to accept the related privileges that we'll assign on the granted user. Below are the steps: cd conf/
ls [[emailprotected] conf]# ls
authz passwd svnserve.conf
vi svnserve.conf
[general]anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
Then create a new file named passwd that will contain alist of users for the SVN repository. Below are the steps:
htpasswd -c /data/svn/repo1/conf/passwd jay
[[emailprotected] conf]# htpasswd -c /data/svn/repo1/conf/passwd jayNew password:
Re-type new password:
Adding password for user jay [[emailprotected] conf