The following short tutorial will guide you through setting up mod dav with apache virtual hosts on ubuntu linux. Assuming you have apache web server installed and running.
The first thing we need to do is run the following commands in the terminal to install the required packages.
sudo apt-get install subversion libapache2-svn
with subversion installed we now need to create the directories for our subversion repository.
sudo mkdir /var/svn sudo mkdir /var/svn/repository sudo chown www-data:www-data -R /var/svn/repository sudo chmod 770 -R /var/svn/repository
next we are going to create a structure which will define how our directories are laid out.
cd ~ mkdir svn-temp mkdir svn-temp/svn mkdir svn-temp/svn/branches mkdir svn-temp/svn/tags mkdir svn-temp/svn/trunk touch svn-temp/svn/trunk/index.html
now we are going to create our repository for our test site `test.example.com` and import our directory structure we just created.
sudo -u www-data svnadmin create /var/svn/repository/test.example.com sudo -u www-data svn import ~/svn-temp file:///var/svn/repository/test.example.com -m"initial import"
Its time for the apache stuff now. We need to create a virtual host and create our web root directory.
sudo mkdir /var/www/test.example.com sudo chown www-data:www-data /var/www/test.example.com
create the file ‘/etc/apache2/sites-available/test.example.com’ and add the following to it:
<VirtualHost *>
DocumentRoot /var/www/test.example.com/svn/trunk
ServerName test.example.com
ServerAlias www.test.example.com
<Location /svn>
DAV svn
SVNPath /var/svn/repository/test.example.com
</Location>
</VirtualHost>
enable the virtual host by typing the following command in the terminal
sudo a2ensite test.example.com
we’re getting there. we need to create our post-commit hook so that when we commit our repository the code will also be updated in the sites web directory also.
create the file ‘/var/svn/repository/test.example.com/hooks/post-commit’ and wirte the following two lines:
#!/bin/sh
/usr/bin/svn update /var/www/test.example.com/ –username www-data
then change the permissions and make it executable
sudo chmod +x /var/svn/repository/test.example.com/hooks/post-commit sudo chown www-data:www-data /var/svn/repository/test.example.com/hooks/post-commit
we now need to be able to view the site in the browser. If you have a dns server already setup you can just configure that, if not you can add test.example.com to the ‘/etc/hosts’ file at the end of the line which starts with 127.0.0.1. so it should look like the following
127.0.0.1 localhost test.example.com
and restart the networking
sudo /etc/init.d/networking restart
Almost there. The last thing we need to do before we can load our website in the browser is the initial checkout and restart apache.
sudo -u www-data svn co file:///var/svn/repository/test.example.com /var/www/test.example.com sudo /etc/init.d/apache2 restart
You can now fire up the browser and type test.example.com in the address bar and should see a blank page, that means everything went fine
Start working on your code by checking out a fresh copy.
cd ~ svn co http://test.example.com/svn testproj
thats all!