Install & Configure SVN Server on Ubuntu 20.04 with Apache2
I recently moved to a new Software company and I was asked to set up new in-house SVN server, having the latest version of Ubuntu (20.04).
SVN stands for Subversion. It is an open-source centralized version control system written in Java, licensed under Apache. Software developers use Subversion to maintain current and historical versions of files such as source code.
Let’s Setup it with 4 Simple and Quick Steps.
- Install Apache2
- Install SVN Package
- Configure Apache2 with SVN
- Create SVN User Accounts.
Step 1: Install Apache2
HTTP Web server is required to install SVN so we will start with installing Apache2. Below Commands will install the Apache on Ubuntu (20.04)
sudo apt update
sudo apt install apache2 apache2-utils
We have installed Apache2 now let’s start and enable it.
sudo systemctl start apache2.service
sudo systemctl enable apache2.service
We have successfully set-up and enable the HTTP web server. Let’s install SVN now.
Step 2: Install SVN
Run the below command and it will automatically install SVN and all dependencies needed for SVN.
sudo apt-get install subversion libapache2-mod-svn subversion-tools libsvn-dev
SVN and all dependencies are installed. Now enable Apache2 modules to run SVN to function.
sudo a2enmod dav
sudo a2enmod dav_svn
sudo service apache2 restart
Step 3: Configure Apache2 with SVN
We have successfully installed Apache and SVN now let’s configure them by editing the config file.
Run the below command to Open config file in the command-line editor.
sudo nano /etc/apache2/mods-enabled/dav_svn.conf
Make mentioned Changes/un-comment lines in the file.
Exit from file editor by saving the changes. (Ctrl + X with Y for Yes)
Let’s Create Repository Now
sudo mkdir /var/www/svn
sudo svnadmin create /var/www/svn/project
sudo chown -R www-data:www-data /var/www/svn
sudo chmod -R 775 /var/www/svn
Step 4: Create SVN User Accounts
Use the below command to create a new SVN user(admin).
sudo htpasswd -cm /etc/apache2/dav_svn.passwd admin
(it will then ask for root password provide that) and Provide password for admin user)
If you wish to create more users then use the below command
sudo htpasswd -m /etc/apache2/dav_svn.passwd awais
then enter the password and re-enter it.
We have successfully Installed and configure SVN let’s restart the Apache2 server and Test it. Restart Apache2 server with the below command.
sudo systemctl restart apache2.service
Let’s Test It
Open your browser and write the following in your URL bar.
http://{your_ip_address}/svn/project
or
http://{your_ip_address}:80/svn/project
80 is default Port but if you need to change it for some reason then you must need to add this after IP address as I changed to 8090
It will ask for SVN username and password which you created above in Step 4
You can get you IP address with the following command in Ubuntu
ip a
Solved Errors:
Error 1:
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
while you start/restart apache2 with command
“sudo systemctl start apache2.service”
or
sudo systemctl restart apache2.service
if you face this error, then in most cases your default port 80 is busy and used by another service.
Solution of Error 1:
Run the Below command to Open ports file and edit that.
sudo nano /etc/apache2/ports.conf
Changed Listen 80
to Listen 8090
Now change the Apache port in the default config file
Exit from file editor by saving the changes. (Ctrl + X with Y for Yes).
Restart the Apache Server and everything should work fine.
If you face any other issue, do mention and I will put that error with the solution in the error listing so that It could help other readers.
If you find anything that needs to be changed in Article don’t forget to share that. Appreciate your suggestions/corrections.