Using the Subversion version control system on a server

Subversion is an open source version tracking system. It keeps files in a central repository and provides version control on directories or files. As a developer, you can check out project files from a repository, make changes to them, and push them back again.

Subversion also has a server component that you can use to host your projects. It works much like an ordinary file server.

How to Install Subversion

Subversion is easy to install. You can use the appropriate command to get your distribution started:

sudo apt install subversion apache2 libapache2-mod-svn

sudo dnf install subversion apache2 mod_dav_svn

Note that this command also installs the Apache2 web server. You will need a web server if you want to access the Subversion repository via HTTP or WebDAV. You can also use HTTPS, you will only need to install and configure a digital certificate to do this.

Once you have run this command, you can verify that subversion is correctly installed. You should now be able to run the svn command and you can see the current version using the –version option:

Server Setup with Subversion

If the installation went well, you can now start working on setting up the repository you will use with svn. Of course, you will have to create a new repository for this. First, create a folder in a root directory to place your repository there:

sudo mkdir /subversion

If you need to access your repository using WebDAV over HTTP, you will need to give Apache ownership of its directory. As Apache uses www-data default user, authorize this user as follows:

sudo chown www-data:www-data /subversion

You can now proceed to www-data user and start working on your repository. The command you would use to log in as www-data the user is:

sudo su -s /bin/bash www-data

You are now an Apache user and after this step you can create your Subversion repository as follows:

svnadmin create /subversion/myrepo

You now have a Subversion repository. To make this repository a bit more secure and identify its users, the next step is to create a user and set a password for them. To do this, use the following command:

htpasswd -cmb /subversion/passwd myadmin mypass

According to this command, your username will be myadmin and your password will be My past. You can modify these values ​​as appropriate for your situation.

Your Subversion repository is now ready to use. At this point, you can leave the www-data user using the go out ordered.

You can now upload a desired project or file to your repository using the command below:

sudo svn import <your-project-address> file:///subversion/myrepo -m "First Commit"

This command uses the import parameter to push everything in your project folder to your Subversion repository. In doing so, you need to add the validation message with the -m setting.

Using Accessor Methods in Subversion

You may have noticed that you are using the case:// protocol to add a project to your repository. This is just one of many network protocols you can use to access an svn repository. You can also use the WebDAV protocol over HTTP or HTTPS, or the subversion custom protocol. svn protocol.

Direct access to the repository

As you have seen, you can use the case:// protocol to access a local repository. Here’s how you can check out a local repository to your current directory:

svn co file:

When you check out the repository, svn displays a list of the files it contains:

Accessing WebDAV Help

To integrate your Subversion repository with Apache, you will need to configure some settings.

For the first step, activate the dave, dav_svnand dav_fs modules using the following commands:

sudo a2enmod dav dav_fs dav_svn

After enabling the required modules, you can now edit the /etc/apache2/mods-enabled/dav_svn.conf case. Create the file if it does not already exist and modify its contents as follows:

<Location /subversion>
DAV svn
SVNPath /subversion/myrepo
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /subversion/passwd
Require valid-user

The AuthUserFile parameter refers to the file you created earlier using htpasswd. Adding it here will grant repository access to all users named in the file, provided they authenticate with a valid password.

Once you have created and saved this file, restart the Apache2 service with the following command:

sudo systemctl restart apache2.service

Now when you open a web browser and navigate to http://localhost/subversion/, you will see the contents of your repository. When you go to this address, you will be asked for your username and password:

Log in with username (eg. myadmin) and password (My past) that you configured earlier. You can access your Subversion repository using WebDAV after entering the username and password:

Access with SSL and WebDAV

The https:// protocol has almost the same configuration as the http:// protocol, with only a few important differences. To give an example, the .conf file you need to use when configuring is different. You must also install a digital certificate. Because as you know, this is the working logic of the SSL encryption method.

You can create a digital certificate yourself or install one issued by a competent authority. Assuming you have a digital certificate installed, what you need to do is simple.

The difference in this step is in the changes you will make to the configuration file. Below is an example configuration file for using SSL and WebDAV:

<Location /subversion>
Options None
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /subversion/passwd
Require valid-user

As you can see, the difference between https:// and http:// protocols is not so much in terms of changes in the configuration file. After these changes, you will need to restart the apache2 service. To run systemctl restart apache2.service do this.

Why use Subversion?

As a version tracker, Subversion remembers every change made to files and directories. It allows you to access older versions of software or documents you are working with and find their differences. This makes it easier to manage projects, especially if your development team is large or distributed.

There are many version control systems for Linux besides Subversion that you might want to consider.

Comments are closed.