Sunday, April 24, 2011


How about we install and configure a version control system while we are at it. Let's install favorite.
$ sudo apt-get install subversion libapache2-svn
Make the directory that we are going to create the repository in, then create the repository, and finally set the ownership to the user that Apache runs as...
$ sudo mkdir /home/<user>/svn
$ svnadmin create /home/<user>/svn
$ sudo chown -R www-data /home/<user>/svn
Now let's create the password file for accessing the repository and one account. It will ask you to enter a password for the new account twice...
$ sudo htpasswd -c /etc/apache2/dav_svn.passwd <user>
Then let's create an authorization file for giving fine grain read/write permissions to particular directories and files in the repository itself. I am just going to give read/write permissions to the entire repository structure...
$ sudo nano /etc/apache2/dav_svn.authz
We need to configure it all together now so you can do this in any place you like but the easiest is in the file below or virtual host file...
$ sudo nano /etc/apache2/mods-enabled/dav_svn.conf
Add or uncomment this text...
<Location /svn>
  DAV svn
  SVNPath /home/<user>/svn
  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile  /etc/apache2/dav_svn.passwd
  AuthzSVNAccessFile /etc/apache2/dav_svn.authz
  Require valid-user
Let's grab our old repository from another instance of subversion and bring it over...
$ svnadmin dump /path/to/repository > repo_name.svn_dump
Then lets suck it up into our new repository on this new server...
$ svnadmin load /home/<user>/svn < repo_name.svn_dump
How about adding SSL to make it all secure. Load this module so we can use SSL...
$ sudo a2enmod ssl
$ sudo a2ensite default-ssl
You may also need to install a couple of additional mods to make it all work depending on your linux distribution or version
sudo a2enmod authz_svn
sudo a2enmod dav_svn
Now you should be able to open you subversion repository using https://localhost/svn and it should work. Try using curl or something like it to test it out locally on your headless server like...
$ sudo apt-get install curl
$ curl -k https://username:password@localhost/svn

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.