Sunday, December 12, 2010

Create subversion repository on Ubuntu

Recently I had to setup a ubuntu box with subversion on it. I had to also provide web access from subversion with authentication. After few hiccups I managed to do this with installing few packages and configuring them.

Step 1: login to your ubuntu box

#ssh root@x.y.z.t

Step 2: Install required packages
#yum install subversion
#yum install mod_dav_svn httpd

Step 3: Create a parent directory where all your repositories will be set up.
#mkdir -p /srv/svn

Step 4: Create a sample repository using svnadmin tool
#svnadmin create /srv/svn/app
In this step we have created a repository named as app.

Step 5: Change the user and group of the created app repository to give the permission to apache user.
#chown -R apache.apache /srv/svn/app
This user is created when you installed httpd package in step 2. Without this step user will not be able to access it via webserver http protocal, they can however access it using command promp using ssh protocol.

Step6: Restart apache webserver.
#service httpd restart

Step 7: Create a password file for the authentication of users which will be accessing your app repository via http protocol.
#mkdir -p /srv/auth/svn/
#htpasswd -c /srv/auth/svn/app.htpasswd ahsan.javed
In this step we are creating a directory first to store the htpasswd file. then using the htpasswd tool we are creating an user name and password hash entry in created file. This htpasswd tool is by default installed when you perform step 2.

Step 8: Create a virtual host for hosting your subversion access
create a new virtual host file at /etc/httpd/conf.d/svn.conf with the content

    LoadModule dav_svn_module     modules/mod_dav_svn.so
    LoadModule authz_svn_module   modules/mod_authz_svn.so

    <Location /repos>
       DAV svn
       SVNParentPath /srv/svn
    </Location>
    <Location /repos/app>
       AuthType Basic
       AuthName "Subversion Repository"
       AuthUserFile /srv/auth/svn/app.htpasswd
       Require valid-user
    </Location>

Step 9: Restart apache webserver
#service httpd restart


Step 10: Access your setup repository in a browser by typing
http://x.y.z.t:80/repos/app
This will ask a user name and password, provide the username and password created in step 7 to access the repository.

Sphere: Related Content

0 comments: