How to Install Apache Subversion (SVN) on Ubuntu 20.04
Apache Subversion (SVN) is a version control system available under the open-source Apache License. Developers commonly use SVN to monitor and manage code and file changes within projects. It provides support for several network access protocols including SVN, SVN+SSH, HTTP, and HTTPS. This tutorial explains the process to install Subversion on Ubuntu 20.04.
Prerequisites
- Set up a Ubuntu 20.04 server with all packages updated.
- Generate a non-root user account with sudo rights.
1. Install Apache2
Begin by setting up the Apache HTTP web server.
$ sudo apt update
$ sudo apt install apache2 apache2-utils -y
Start Apache service:
$ sudo systemctl start apache2
Enable Apache to start at boot time:
$ sudo systemctl enable apache2
2. Install Apache Subversion
First, install necessary dependency packages:
$ sudo apt-get install libapache2-mod-svn subversion-tools libsvn-dev -y
When prompted, choose the Internet Site default configuration.
Then, install Subversion:
$ sudo apt install subversion -y
Activate required Apache modules for SVN:
$ sudo a2enmod dav
$ sudo a2enmod dav_svn
Restart Apache service to apply changes:
$ sudo systemctl restart apache2
3. Configure Apache2 for SVN
Open the SVN configuration file in Apache for editing:
$ sudo nano /etc/apache2/mods-enabled/dav_svn.conf
Ensure the file matches the following configuration before saving and exiting:
Alias /svn /var/www/svn
<Location /svn>
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
Create the SVN project directory:
$ sudo mkdir /var/www/svn
$ sudo svnadmin create /var/www/svn/project
Adjust permissions for the repository:
$ sudo chown -R www-data:www-data /var/www/svn
$ sudo chmod -R 775 /var/www/svn
4. Create SVN Admin Accounts
Add a new SVN user named admin
:
$ sudo htpasswd -cm /etc/apache2/dav_svn.passwd admin
Restart Apache to apply user authentication settings:
$ sudo systemctl restart apache2
To view the repository in your browser, navigate to:
http://server_IP/svn/project
Example:
http://192.0.2.10/svn/project
Conclusion
You have now completed the installation and configuration of Apache Subversion (SVN) on your Ubuntu 20.04 server. By following the steps in this guide, you installed the Apache2 web server, configured the necessary modules, set up SVN repositories, and secured access with basic authentication. Your system is now ready to manage version-controlled projects efficiently and securely.
SVN is a powerful and reliable tool for tracking changes in codebases and managing collaborative development. It provides a stable environment for teams that require centralized version control. With your repository up and running, you can start organizing your code, enforcing access rules, and integrating SVN into your development workflow.
Make sure to maintain regular backups of your repositories and monitor access logs to ensure security and integrity. As your projects grow, you can further enhance SVN by integrating web interfaces, hooks for automation, or migration to more advanced repository structures.
For advanced configuration options and best practices, consult the official Apache Subversion documentation. With this foundation in place, your development team can work more effectively, keep track of every change, and maintain full control over your code history.