Friday, August 3, 2012

Configure Subversion with Apache web server on Ubuntu

Its easy to have a private subversion repository that you can access from anywhere, all you need:
  1. Subversion
  2. Apache Web server
  3. Ubuntu (Soon i'll publish for Windows) 

Install Apache server on ubuntu

sudo apt-get update
sudo apt-get install apache2
view raw gistfile1.sh hosted with ❤ by GitHub

make sure your Apache server is up and running 

Install subversion on ubuntu

sudo apt-get install subversion
view raw gistfile1.sh hosted with ❤ by GitHub

The above command installs subversion but in order to access your subversion via internet you need to configure your subversion with Apache. Subversion provides module to interact with Apache such as libapache2-svn, install the package using the following command:
sudo apt-get install libapache2-svn
view raw gistfile1.sh hosted with ❤ by GitHub

Subversion configuration

Create a subversion folder to hold all the repositories. 
sudo mkdir /var/lib/svn
view raw gistfile1.sh hosted with ❤ by GitHub
Once you create the subversion directory open and edit the subversion configuration file located in the "mods-enabled" in the "apache2" located in "etc" with following command.
sudo gedit /etc/apache2/mods-enabled/dav_svn.conf
view raw gistfile1.sh hosted with ❤ by GitHub
 
uncomment the following line in the dav_svn.conf file

<location svn="svn">
DAV svn
SVNParentPath /var/lib/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
<location>
view raw dav_svn.conf hosted with ❤ by GitHub

Once the configuration finished. Create the user craditial to login to the subversion with the following command:

sudo htpasswd2 -cm /etc/apache2/dav_svn.passwd rambo
view raw gistfile1.txt hosted with ❤ by GitHub


 Restart the Apache server
sudo /etc/init.d/apache2 restart
view raw gistfile1.txt hosted with ❤ by GitHub

Create a simple subversion repository project


svnadmin create /var/lib/svn/myproject
view raw gistfile1.txt hosted with ❤ by GitHub
Once the project is created, change the permission of the project directory to enable the web user to read/write.
sudo chown -R www-data:www-data /var/lib/svn/myproject
view raw gistfile1.txt hosted with ❤ by GitHub
Done! Open the subversion repository by click this link  http://localhost/svn/myproject

So far you can access your subversion repository in the local network but you also can make it available to the wide area network with the domestic router and internet connection. I will be posting about it soon as possible.

No comments: