Saturday, 7 December 2024
How To's Ubuntu

How to setup SVN Server on Ubuntu 14.04 LTS with Web Access

SVN (Subversion) is an opensource version control system. it is used to store previous changes of your project files like documentation, coding etc. also you can track and identify who made the particular changes in the project files .
In this article we will guide you how to install SVN Server on Ubuntu 14.04 Server Edition or LTS Edition.
 
To setup SVN Server on ubuntu 14.04 server edition.
1. First installed/update ubuntu repositories with the following command.

sudo apt-get update

2. After updating the repositories we can now install the SVN and apache webserver, we need apache in able to access our SVN  repo through http/web access.
 
To install apache and SVN,

sudo apt-get install subversion apache2 libapache2-svn apache2-utils

3. Next is to create a directory where you want to keep your repositories.
for my default setup i used: /svn/

sudo mkdir -p /svn/

and edit dav_svn.conf file

sudo nano /etc/apache2/mods-enabled/dav_svn.conf

Default config

# dav_svn.conf - Example Subversion/Apache configuration
#
# For details and further options see the Apache user manual and
# the Subversion book.
#
# NOTE: for a setup with multiple vhosts, you will want to do this
# configuration in /etc/apache2/sites-available/*, not here.
#  ... 
# URL controls how the repository appears to the outside world.
# In this example clients access the repository as http://hostname/svn/
# Note, a literal /svn should NOT exist in your document root.
#
  # Uncomment this to enable the repository
  #DAV svn
  # Set this to the path to your repository
  #SVNPath /var/lib/svn
  # Alternatively, use SVNParentPath if you have multiple repositories under
  # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
  # You need either SVNPath and SVNParentPath, but not both.
  #SVNParentPath /var/lib/svn
  # Access control is done at 3 levels: (1) Apache authentication, via
  # any of several methods.  A "Basic Auth" section is commented out
  # below.  (2) Apache  and , also commented out
  # below.  (3) mod_authz_svn is a svn-specific authorization module
  # which offers fine-grained read/write access control for paths
  # within a repository.  (The first two layers are coarse-grained; you
  # can only enable/disable access to an entire repository.)  Note that
  # mod_authz_svn is noticeably slower than the other two layers, so if
  # you don't need the fine-grained control, don't configure it.
  # Basic Authentication is repository-wide.  It is not secure unless
  # you are using https.  See the 'htpasswd' command to create and
  # manage the password file - and the documentation for the
  # 'auth_basic' and 'authn_file' modules, which you will need for this
  # (enable them with 'a2enmod').
  #AuthType Basic
  #AuthName "Subversion Repository"
  #AuthUserFile /etc/apache2/dav_svn.passwd
  # To enable authorization via mod_authz_svn (enable that module separately):
  #
  #AuthzSVNAccessFile /etc/apache2/dav_svn.authz
  #
  # The following three lines allow anonymous read, but make
  # committers authenticate themselves.  It requires the 'authz_user'
  # module (enable it with 'a2enmod').
  #
    #Require valid-user
  # 
#

Uncomment the following and your done.

DAV svn
SVNParentPath /svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user

4. To create a svn user simple run the following command.

sudo htpasswd -cm /etc/apache2/dav_svn.passwd pr3p

Then input the requireed password for the user.
5. Ok lets create svn repo directory for your files.

cd /svn
sudo svnadmin create test_repo

Make sure you set the permissions of the /svn directory to apache with the following command:

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

6. Restart the apache2 service:

sudo /etc/init.d/apache2 restart

7. Ok almost done lets test the svn server, on your windows machine create a folder and right click and select the SVN Checkout, and type the domain url of your repository file.
To view the svn repositories on web, just go to browser and type the server ip/domainame with svn repo folder, on my end my server ip address http://192.168.221.222/svn/test_repo and input the required user authentication.
user: pr3p
pass: ****
Web Access:
svnpr3p
 
8. In able to checkout or do commits download svn tortoise  tools
TortoiseSVN is free software for software developers (programmers). It helps programmers manage different versions of the source code for their programs.
Download here: http://tortoisesvn.net/
 
svncheckout
svn2
Enter the repository’s URL and click OK, it will be prompted for a login and password. Enter the login information and click OK.
9. Create some test file inside the checkout repository, Right-Click and Select the SVN Commit:
svntestfile
10. Enter the comments that describe the purpose of this commit:
svncommit
11. and congrats your SVN Server is pretty working fine, the result would be like this
svnrev
 
Enjouy cyah….

Post Comment