How to Install Apache SVN (Subversion) on CentOS 7.x / RHEL 7.x

January 26, 2015 | By
| 8 Replies More

Hi everyone, today in this tutorial we'll be installing Apache SVN also popular as Subversion on our CentOS 7 or RHEL 7 which  is an awesome tool for version control system which is suitable from small project to large projects.  So, here is some information on what really is Apache SVN (Subversion).

Apache Subversion (often abbreviated SVN, after the command name svn) is a software versioning and revision control system distributed as free software under the Apache License. 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.

So, Lets install SVN in our CentOS / RHEL 7 . We'll need to install a Web Server first of all to make our Subversion working. Here are the steps below which will let us fully setup it out of the box.

1. Installing a Web Server

So, before we install a Web server, we'll need to update the yum package repository:

# yum update

Now, we will install Apache server as web server for the SVN repository.

# yum -y install httpd httpd-tools

install httpd

Now, we'll need to allow http through our firewall. You can do that with the command below.

# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --reload

firewalld cmd

If you get error like we have got above, then you must be sure that Firewalld is not installed or not running. So, you'll need to install firewalld using "yum install firewalld" and start the service with "systemctl start firewalld" without quotes("") as shown above .

Now, we'll wanna start our Apache and verify if its running fine by visiting http://localhost or http://ip-address .

# systemctl start httpd.service

start-httpd.service

2. Installing Subversion

Once the Apache Web Server is installed, we'll need to execute the following command to install subversion.

# yum -y install subversion subversion-tools mod_dav_svn

install subversion

3. Configuring Subversion

After we've done installing subversion, we can now start to create repositories as per the requirements. In our case we'll be creating /svn as the base and will create the repository in it.

Note: You can select the directory where you wanna create your Repository and replace /svn with it.

# mkdir /svn

Now, we'll create a repository called “linoxiderepo” under "/svn/" directory as

# svnadmin create /svn/linoxiderepo

Change the permission of the repository in such a way that Apache can read and write it.

# chown -R apache:apache /svn/linoxiderepo/

configuring subversion

If you have SELinux enabled on the system, run the following command.

# chcon -R -t httpd_sys_content_t /svn/linoxiderepo/
# chcon -R -t httpd_sys_rw_content_t /svn/linoxiderepo/

4. Configuring Apache Server

Configure virtual host in Apache.

# nano /etc/httpd/conf.d/svn.conf

Place the following content.

<location /svn>
DAV svn
SVNParentPath /svn
</location>

configuring apache server

Then, we'll need to restart the apache server to take effect.

# systemctl reload httpd.service

reload httpd

Now, we should be able to access the SVN using your favorite browser, we'll need to go to http://our-ip-address/svn/linoxiderepo . It wont ask us any password to view so, it makes our SVN repository publicly accessible. If we want to secure our SVN repository then, we'll need to follow the steps below.

5. Securing SVN: (Optional)

The above setting would allow the anonymous users to view and committing the files. To stop the anonymous access, you have to edit the apache configuration which was created just two steps before.

# nano /etc/httpd/conf.d/svn.conf

We'll gonna add the following contents in that file.

<location /svn>
DAV svn
SVNParentPath /svn/
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /etc/subversion/svn.users
Require valid-user
</location>

secure svn.conf

Created the password file for the user.

# htpasswd -cm /etc/subversion/svn.users arun

Now, Restart the apache server.

# systemctl reload httpd.service

secure svn repo

6. Testing Subversion

Finally we can visit the url http://our-ip-address/svn/linoxiderepo in our browser to check out the content, you will be asked to enter the user name and password (If you have setup the Secure SVN).

Upon successful login, contents will be listed like below.

Create a template directory and import into SVN.

# mkdir -p /tmp/repository/project/{trunk,branches,tags}
# svn import -m 'Initial Import' /tmp/repository/project/ http://192.168.12.103/svn/linoxiderepo

svn import shell

In the Browser after the import.

svn import

Conclusion

Hurray! We have successfully installed Apache SVN (Subversion) along with Apache Web Server to host the repository in our CentOS 7. This tutorial is also applicable for RHEL 7 (Red Hat Enterprises Linux) . Apache SVN  is an awesome tool for version control system which is suitable from small development project to huge projects. We'll need a SVN client such as Tortoisesvn for windows and Rapidsvn for Linux which are some good GUI front-end for the Subversion revision system . So, if you have any questions, comments, feedback please do write on the comment box below and let us know what stuffs needs to be added or improved. Thank You! Enjoy Apache SVN (Subversion) :-)

Filed Under : LINUX HOWTO, WEB SERVERS

Free Linux Ebook to Download

Comments (8)

Trackback URL | Comments RSS Feed

  1. a says:

    svn 1.7 is old version :( ... how install svn 1.8? on rhel7?

  2. Arun Pyasi says:

    Hi there, to install svn v1.8 on RHEL7, all the steps above is the same, you just need to add a repository for svn 1.8 in step 2 (just before installing subversion).
    You'll need to create a new file /etc/yum.repos.d/wandisco-svn.repo and add the following lines in it.

    [WandiscoSVN]
    name=Wandisco SVN Repo
    baseurl=http://opensource.wandisco.com/centos/7/svn-1.8/RPMS/$basearch/
    enabled=1
    gpgcheck=0

    After adding the above lines to the repo file. Enter the following command in a shell or terminal :
    # yum clean all
    then, install subversion from above step 2.

    • Tyler says:

      ... but @Arun, svn_mod_dav is not available at the location you gave, at wandisco.

      • Arun Pyasi says:

        Hi Tyler thanks for your comment. The installation for svn_mod_dav is mentioned in the step no. 2 which you can install with yum install svn_mod_dav too. Thanks :)

        • Pedro Rodrigues says:

          I think the question is if subversion-libs 1.7.14-7 from the Centos 7 repo will work with the Subversion 1.8 binaries. After all they are supposed to match.

        • Pedro Rodrigues says:

          Subversion-libs 1.7.14-7 is a dependency of svn_mod_dav, forgot to mention.

  3. Sisila Priyanka says:

    nice and clear tutorial...... (Y)

  4. Vignesh says:

    Hello sir,

    Thanks.Ur tutorial is awesome, but can u pls add how to access the svn with LDAP users,.(Means needs to be integrate svn with LDAP)

    Thanks

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.