How to install Apache Subversion on Ubuntu 18.04 LTS

SVN server lets you record changes to a file or set of files over a period of time.

-Advertisement-

Apache Subversion (known commonly as SVN) is a very popular open source version control system. A version control system lets you record changes to a file or set of files over a period of time so that you can recall specific versions when there is a need.

In order to have version control for your project, you first need to install SVN server on your Ubuntu machine.

Installing SVN Server on Ubuntu 18.04 LTS

Here we are going to install and configure Apache subversion on Ubuntu 18.04 LTS.

Step 1. Install Apache

Before we go ahead with the installation, let us first update repository.

-Advertisement-
sudo apt-get update
sudo apt-get install apache2

Check apache status.

sudo systemctl status apache2
-Advertisement-

If service is not yet started, then .start Apache.

sudo systemctl start apache2

Enable Apache on system boot.

sudo systemctl enable apache2
-Advertisement-

Verify Apache Installation. Just open your web browser and type web server IP or hostname. If you can see the Apache default page, Apache installation is successful.

Step 2. Install Apache Subversion

Install subversion and required packages

 sudo apt-get install subversion libapache2-mod-svn

After installation, it automatically enables the needed SVN modules (dav_module , dav_svn_module, authz_svn_module ).

List the enabled modules

sudo apachectl -M

If svn modules are not enabled. run below commands and enable it

sudo a2enmod dav
sudo a2enmod dav_svn
sudo a2enmod authz_svn

After enabling those modules, we need to restart the Apache service.

sudo service apache2 restart

Step 3. Configure Apache Subversion

Now we are going to create the SVN repository. Here we use “/opt” directory to create our repository.

Create svn directory.

sudo mkdir -p  /opt/svn

Create svn repository. Here we create a repository called “fosslinuxrepo”

sudo svnadmin create /opt/svn/fosslinuxrepo

Changing ownership of the repository.

sudo chown -R www-data:www-data /opt/svn/fosslinuxrepo/

Changing permissions of the repository.

sudo chmod -R 775/ opt/svn/fosslinuxrepo

Add Subversion Users. Here we create a password file in the “/etc” directory.

sudo htpasswd -cm /etc/svn-auth-users  fosslinux

Create the second user.

sudo htpasswd -m /etc/svn-auth-users fosslinux2

Create Apache virtual host file for SVN- in order to do this we first need to change directory to “/etc/apache2/sites-available/”

cd /etc/apache2/sites-available/

Create a virtual host file and here we create a file called “fosslinuxsvn.conf”.

sudo vim fosslinuxsvn.conf

Add following lines to file.

<VirtualHost *:80>
        ServerName svn.fosslinux.com
        ServerAlias svn.fosslinux.com
        <Location /svn>
     DAV svn
     SVNParentPath /opt/svn
     AuthType Basic
     AuthName "Subversion Repository"
     AuthUserFile /etc/svn-auth-users
     Require valid-user
</Location>
    ErrorLog ${APACHE_LOG_DIR}/svn.fosslinux.com-error.log
    CustomLog ${APACHE_LOG_DIR}/svn.fosslinux.com-access.log combined
</VirtualHost>

Change “svn.fosslinux.com” to your hostname.

Save and exit the file.

Disable default virtual host file.

sudo a2dissite 000-default.conf

Enable newly created virtual host file.

sudo a2ensite fosslinuxsvn.conf

Check apache syntax.

sudo apachectl -t

Then restart Apache.

sudo systemctl restart apache2

Step 4. Test Configured Apache Subversion

Open the web browser and type repo URL and hit enter.

http://svn.fosslinux.com/svn/fosslinuxrepo/

Replace sv.fosslinux.com with your hostname.

When you will get the Authentication popup screen, enter the already created Username and Password to access svn repository.

Authentication
Authentication

Now you can see the created repository.

SVN-Repo
SVN-Repo

Let us now create a project called “RnD_works ” inside the repository.

svn mkdir file:///opt/svn/fosslinuxrepo/RnD_works -m "added RnD_works repository"
svn mkdir file:///opt/svn/fosslinuxrepo/RnD_works/trunk -m "added RnD_works trunk repository"
svn mkdir file:///opt/svn/fosslinuxrepo/RnD_works/branches -m "added RnD_works branches repository"
svn mkdir file:///opt/svn/fosslinuxrepo/RnD_works/tags -m "added RnD_works tags repository"

Let us check if this new project can be viewed inside the repository.

New Project
New Project

Click and Open “RnD_works”

Inside Project
Inside Project

If you want to delete a created project you can use below command to delete it.

svn delete file:///opt/svn/fosslinuxrepo/RnD_works -m "delete RnD_works repository"

Step 5. Schedule Repository Backup

Create a backup folder.

sudo mkdir -p /etc/backcups

Change user to root user.

sudo su -

Edit crontab.

crontab -e

In the following command, we schedule svn backup midnight every day.

0 0 * * * svnadmin dump /opt/svn/fosslinuxrepo > /etc/backcups/svnbackups-$(date +%Y%m%d).dump

CronJob
CronJob

Then save and exit.

Step 6. Restore Repository

If you need to restore svn repository from backup file use below commands.

Create a new repository.

svnadmin create /opt/svn/restorerepo

Restore backup:

svnadmin load /opt/svn/restorerepo < /etc/backups/svnbackups-20190204.dump

That’s all. We hope this article has helped you to configure subversion successfully. If you have any questions or comments, please visit the Comments section below.

-Advertisement-
Darshana
Hey! I'm Darshana, a Linux / DevOps Engineer and also a contributor to FOSS Linux. I enjoy working on various kind of Linux distributions and cloud technologies. During my free time, I love to swim and hike across nature trails. Linux is my love and I'm here to share all my learnings with all of you! Hope you enjoyed reading my article.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,631FansLike
360FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

Top 20 Git Commands with Practical Examples

If you are here reading this post, there is a high probability that you have heard or interacted with Github, and you now want to learn Git. Before we continue with showing you some of the cool Git commands, let's understand the difference between Git and GitHub.

Top 10 New Features in Linux Kernel 5.7

Linus Torvalds has announced the release of Linux Kernel 5.7 after seven weeks of development. The release announcement comes as a piece of exciting news as it brings a host of new features for the hardware manufacturers as well as the developers.

How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

[Guide] apt vs apt-get commands, and which one to use?

Most Linux users, both veterans, and newbies, often get confused about what the difference between the Linux commands apt, and apt-get are and when they should use one or the other.

Ubuntu 19.10 (Eoan Ermine) Beta Installation and Overview

It may be early, but I've been looking forward to the release of Ubuntu 19.10 for some time now. As an impatient person, and promised readers in the FOSSLinux article announcing the release of Eoan Ermine that we would provide you a review of Ubuntu 19.10 Eoan Ermine - Beta.  So, here it goes.

10 ways to use the Chown command with examples

Any file in a Linux system belongs to a particular owner(s) and a group. It is one of the many features that maintain security in Linux systems. For example; If a file belongs to say UserA, then UserB cannot manipulate the data depending on any additional permissions set unless the user has permission to do that.

Installing multiple Linux distros on a USB drive

A bootable Linux USB drive, which also referred to as a Live USB drive, is a drive containing files that enable a computer to boot into a specific Linux distro. It is most commonly used to test-drive various Linux distros before installing on the computer for use as a daily driver.