How to setup a Subversion (SVN) in AMAZON EC2 Ubuntu 14.04

How to setup a Subversion (SVN) in AMAZON EC2 Ubuntu 14.04

  • 2016-09-19
  • 357

Setting up a SVN Server for Small to Mid Size Project handling in Amazon EC2 Server with Operating System Ubuntu Server is an general process. But this is an non trivial process, when we look it from a programmer perspective. I have recently configured such one and hence making documentation of the same. May be it will help someone.

We assume that Amazon EC2 server is configured with SSH already.
Now, first we need to update the Existing Operating System with

sudo apt-get update
sudo apt-get dist-upgrade

Apache, PHP, MYsql Setup

We have to install and configure Apache as web server to make access of the SVN through HTTP.

sudo apt-get install apache2

We have to enable rewrite module in apache.

sudo a2enmod rewrite

We had to configure PHP to run with apache server.

apt-get install libapache2-mod-php5
apt-get install libapache2-mod-php5

And then restart the Apache Server.

sudo service apache2 restart

Now we had added the default user and group “www-data” to run apache server in ubuntu and made the required permission for those.

sudo adduser ubuntu www-data
sudo chown -R www-data:www-data /var/www
sudo chmod -R g+rw /var/www

Made another server Restart

sudo /etc/init.d/apache2 restart
We have installed mysql and php mysql driver to work the apache server seamlessly.

sudo apt-get install mysql-server
sudo apt-get install php5-mysql
sudo /etc/init.d/apache2 restart

Subversion Setup

We have installed the subversion and related tools and apache svn module in our ec2 ubuntu instance.

sudo apt-get install subversion
sudo apt-get install libapache2-svn
sudo apt-get install subversion-tools

We have created folder for SVN in /home folder. And made a test directory by using svnadmin tool. Also we have made necessary permission for the folders to the user “www-data”.

sudo mkdir /home/svn
sudo mkdir ~/test
sudo svnadmin create /home/svn/test
cd /home/svn
sudo chown -R www-data:www-data /home/svn
sudo chown -R www-data:www-data /home/svn

Now as the new apache configuration has changed the folder structure and the enabled module related configuration are to be done in mods-enabled folder. For configuring svn, we needed to configure dav-svn.conf

cd /etc/apache2/
cd mods-enabled/
sudo nano /etc/apache2/mods-enabled/dav-svn.conf

The changed configuration is

<Location /repos>
   DAV svn
   SVNParentPath /home/svn
   # Limit write permission to list of valid users.
   AuthType Basic
   AuthName "Authorization Realm"
   AuthUserFile /home/svn/svn-auth/passwd
   AuthzSVNAccessFile  /home/svn/svn-auth/access
   Require valid-user

Made another server Restart

sudo service apache2 restart

Rest of the works are relatively simple. We made 2 folders in SVN for our work

sudo svnadmin create /home/svn/mobilesvn
sudo svnadmin create /home/svn/serversvn

We had made the users to have access to the SVN folders.

sudo mkdir /home/svn/svn-auth/
sudo nano /home/svn/svn-auth/access

admin = rw
mobileuser = rw
serveruser = rw

Now to create password for the users, we needed to install the apache2-utils utility.

sudo apt-get install apache2-utils

We had created password

sudo htpasswd -cb /home/svn/svn-auth/passwd admin ADMINPASS
sudo htpasswd -b /home/svn/svn-auth/passwd mobileuser MOBPASS
sudo htpasswd -b /home/svn/svn-auth/passwd serveruser SRVPASS

Again, we have ensured the necessary permissions for the folders, so that they can not be accessed from external interface.

sudo chown -R www-data.www-data /home/svn /home/svn/svn-auth/
sudo chmod 600 /home/svn/svn-auth/access /home/svn/svn-auth/passwd
sudo service apache2 restart

To ensure apache server at startup of the operating system, we made -

sudo apt-get install sysv-rc-conf
sudo sysv-rc-conf apache2 on
sudo sysv-rc-conf apache2 --list

So our server configuration is completed here.

Subversion Setup

Now to test on client side, to make everything is ok

We have tested with our local box, which is connected to the internet

svn checkout http://<<Elastic IP>>/svn/mobilesvn mobilesvn
gedit mobile-initial.txt
svn add mobile-initial.txt 
svn commit -m 'initial commit'
svn up

svn checkout http://<<Elastic IP>>/svn/serversvn serversvn
gedit server-initial.txt
svn add server-initial.txt 
svn commit -m 'initial commit'
svn up

Now, when we accessed the above URLs, we have found the initial committed files in SVN.

So that is all.


Angular 2 Fundamentals for Web Developers

The Unreal Engine Developer Course - Learn C++ & Make Games

The Complete Web Development Tutorial Using React and Redux

Learn Web Development Using HTML5 Advanced Programing

Create Complete Web Apps without Coding