This tutorial will show you how to install subversion server (SVN) step by step and publish it in Apache in CentOS/RHEL Linux.
So first, a quick wiki:
Apache Subversion (often abbreviated SVN, after the command name) is a software versioning and revision control system distributed as free software under the Apache License.[1] Developers use Subversion to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly compatible successor to the widely used Concurrent Versions System (CVS).
The free software community has used Subversion widely: for example in projects such as Apache Software Foundation, Free Pascal, FreeBSD, GCC, Mono and SourceForge. Google Code also provides Subversion hosting for their free software projects. CodePlex offers access to Subversion as well as to other types of clients.
The corporate world has also started to adopt Subversion. A 2007 report by Forrester Research recognized Subversion as the sole leader in the Standalone Software Configuration Management (SCM) category and as a strong performer in the Software Configuration and Change Management (SCCM) category.[2]
Table of Contents
System requirements:
A CentOS/RHEL Linux machine connected to the internet.
SVN Installation:
Install subversion like so:
[root@server ~]# yum install -y subversion mod_dav_svn
If you haven’t installed Apache already then the above command will install it respectively.
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 <Location /svn> DAV svn SVNParentPath /home/svn AuthType Basic AuthName "Subversion repositories" AuthUserFile /etc/svn-auth-users Require valid-user </Location>
Next, let’s create a user for Subversion, called itai for exmaple:
[root@server ~]# htpasswd -cm /etc/svn-auth-users itai New password: Re-type new password: Adding password for user itai
Create and configure Subversion Repository:
Create a directory for subversion repository under ‘/var/www/’ or as I personally prefer creating the svn folder in /home for example and then create a symbolic link to /var/www/, like so:
In order to create the symbolic link, run the next command:
[root@server ~]# mkdir /home/svn [root@server ~]# ln -s /home/svn /var/www/ [root@server ~]# ls -l /var/www total 16 drwxr-xr-x 2 root root 4096 2013-08-13 20:30 cgi-bin drwxr-xr-x 3 root root 4096 2013-11-25 10:39 error drwxr-xr-x 2 root root 4096 2013-08-13 20:30 html drwxr-xr-x 3 root root 4096 2013-11-25 10:39 icons lrwxrwxrwx 1 root root 9 2013-11-25 10:44 svn -> /home/svn [root@server ~]#
Then, create the repo itself and change it’s ownership to apache user.
[root@server svn]# svnadmin create geekkb_repo [root@server svn]# chown -R apache.apache geekkb_repo
Note: If SELinux is enabled in your machine, run the following commands to change the SELinux context security.
[root@server svn]# chcon -R -t httpd_sys_content_t /var/www/svn/geekkb_repo/ [root@server svn]# chcon -R -t httpd_sys_rw_content_t /var/www/svn/geekkb_repo/
Note: If iptables is running, make sure you open port ’80’:
[root@server svn]# 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
Restart the iptables to save the changes:
[root@server svn]# /etc/init.d/iptables restart iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ] iptables: Applying firewall rules: [ OK ]
Start/Restart Apache:
[root@server svn]# /etc/init.d/httpd start Starting httpd: [ OK ] [root@server svn]# chkconfig httpd on
Test Subversion:
Open your favorite internet browser and browse to: https://hostname/repo_name
Enter the username and password we created earlier and click OK:
After logging in to should look like this:
Disable anonymous login:
If you want to disable the option on anonymous users logging into the repository, just edit the following line in:’ your_repo/conf/svnserve.conf’ file, in my case it’s ‘/home/svn/geekkb_repo/conf/svnserve.conf’:
[root@server ~]# vi /var/www/svn/geekkb_repo/conf/svnserve.conf
## Line number 12 – Uncomment and change to ‘none’ ##
anon-access = none
## Line number 27 – Uncomment to enable access control ##
authz-db = authz
Create additional links(directories) under Subversion Repository:
[root@server ~]# mkdir svn-templates [root@server ~]# cd svn-templates/ [root@server svn-templates]# mkdir softwares [root@server svn-templates]# mkdir updates [root@server svn-templates]# mkdir fixes
Now import the sub-directories using the command 'svn import' , like so:
[root@server] # svn import -m 'Initial import' svn-templates/ https://hostname/repo_name
Example:
Now check for the changes in your repository:
Now your newly created directory structure will be listed under your main repository. Thats it.
If that’s the SVN configuration you’ll be using (svn-apache) then in order to add users, you’ll have to:
htpasswd -m /etc/svn-auth-users username set a password
Log in using the newly created credentials.
Feel free to leave comments or ask questions!
No Comments Yet