How to setup SVN server on Ubuntu ?

How to setup SVN server on Ubuntu ?

Install Subversion Server on Ubuntu Machine.

Why Subversion ?
Apache Subversion is a full-featured version control system originally designed to be a better CVS. Subversion has since expanded beyond its original goal of replacing CVS, but its basic model, design, and interface remain heavily influenced by that goal. Even today, Subversion should still feel very familiar to CVS users.

There are few steps below-:

Step 1-:
Install required packages.

$ sudo apt-get update
$ sudo apt-get install apache2 subversion websvn libapache2-svn php5 php5-svn

If you found error like below-:

Creating config file /etc/websvn/ with new version
ln: failed to create symbolic link ‘/etc/apache2/conf.d/websvn’: No such file or directory
dpkg: error processing package websvn (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.21-0ubuntu4) ...
Processing triggers for libapache2-mod-php5 (5.6.4+dfsg-4ubuntu6.4) ...
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please use the below commands

$ sudo mkdir /etc/apache2/conf.d

Reinstall the packages.

Create symbolic links

 ln -s /etc/websvn/apache.conf /etc/apache2/conf-available/websvn.conf

Enable the websvn configuration using below command.

$ sudo a2enconf websvn.conf

Enable the dav and dav_svn modules

$ sudo a2enmod dav
$ sudo a2enmod dav_svn
$ sudo service apache2 reload

Step 2-:

Create the Subversion Environment.

$ sudo mkdir -p /var/lib/svn/FirstRepo
$ sudo svnadmin create --fs-type fsfs /var/lib/svn/FirstRepo
$ sudo chmod -R 775 /var/lib/svn

Add User admin for repository authentication.

$ sudo htpasswd -c /etc/global.htpasswd admin

Step 3-:

Open the dav_svn.conf file.

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

Add the below content bottom of the file.

DAV svn
SVNParentPath /var/svn

 $ sudo service apache2 reload

Open the file.

 $ sudo nano /etc/websvn/

Modify the below line for the websvn.

$config->addRepository("FirstRepo", "file:///var/lib/svn/FirstRepo");

Step 4-:

Test the Subversion Server.
Checkout the FirstRepo

svn co


Authentication realm: <> FirstRepo Subversion Repository
Password for 'root': 

Authentication realm: <> FirstRepo Subversion Repository
Username: admin
Password for 'admin': *********

ATTENTION!  Your password for authentication realm:

   <> FirstRepo Subversion Repository

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
Store password unencrypted (yes/no)? no
Checked out revision 0.

Additional Part of this Article.

If you want to create SVN Repository using script. Create a file like

 $ nano

Copy all the below content into this file.

if [ -z "${PositionalParamExists}" ]; then
 echo "Please enter proper Repository Name"
svnadmin create /var/lib/svn/$1
chmod -R 775 /var/lib/svn/$1
chown -R www-data:www-data /var/lib/svn/$1
echo "<Location /svn/$1>
 AuthType Basic
 AuthName \"$1 Subversion Repository\"
 AuthUserFile /etc/global.htpasswd
 Require user admin 
</Location>" >> /etc/apache2/mods-enabled/dav_svn.conf
nano /etc/apache2/mods-enabled/dav_svn.conf
/etc/init.d/apache2 reload

Save the file.

$ sudo chmod +x
Run the script.
$ sudo sh


$ sudo ./
Gotechnies Websvn Blog

Rating: 4.9
Votes: 375
Reviews: 330

Post a comment