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

Channel: Linux
Abstract: 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

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.

How to Install CentOS in VMware wor...

To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video

How to Install CentOS in VMware workstation player (CentOS Linux 8)

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, let's install SVN in our CentOS or RHEL 7 machine. We'll need to install a Web Server first to make our Subversion working. Here are the steps below which will let us fully set up 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

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

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
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
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/

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>

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

# systemctl reload httpd.service

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 anonymous users to view and commit 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>

Created the password file for the user.

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

Now, Restart the apache server.

# systemctl reload httpd.service
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


In the Browser after the 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 ( 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).

Ref From: linoxide
Channels:

Related articles