Simple procedure to install SVN repositories and publish them on Apache web server.
These steps are applied for Ubuntu Linux (tested on 11.04, 10.04, 9.04) . I have done also on Windoze several times but there were much more efforts so I don’t recommend Redmond at all.
Installing software on Ubuntu Linux are very easy with the Debian package-manager (dpkg -i *.deb), which is wrapped by apt-get (or aptitude). Some people prefer GUI tools such as Synaptic (or Ubuntu Software), but afterall those tools use apt-get or aptitude in the back-end , so please bear with my way (CLI) for a while ;-) .
Update index of repositories :
$ sudo apt-get update
$ sudo apt-get upgrade
Kill processes which are binding to port 80 TCP :
$ sudo fuser -k 80/tcp
Install Apache HTTPD with SSL
Install Apache2 server from Ubuntu repository
$ sudo apt-get install apache2
Enable mod SSL for Apache
$ sudo a2enmod ssl
Configure Apache to listen on HTTPS port (443) with all hostname
$ sudo gedit /etc/apache2/ports.conf
... NameVirtualHost *:80 Listen 80 <IfModule mod_ssl.c> # SSL name based virtual hosts are not yet supported, therefore no # NameVirtualHost statement here NameVirtualHost *:443 Listen 443 </IfModule> ...
Enable SSL for configured sites
$ sudo a2ensite default-ssl
Now restart Apache to apply above changes:
$ sudo /etc/init.d/apache2 restart
Note that from now Apache HTTPD data is under control of www-data user and a www-data group, although they seems transparent.
You can check the Apache server by using browser :
http://localhost/ or https://localhost/
Install Subversion, WebDAV and expose to Apache
Install subversion, both client (svn) and server (svnserve, svnadmin)
$ sudo apt-get install subversion
Check the server and client tools :
$ svn –version
$ svnadmin –version
Install WebDAV and svn tools for Apache :
$ sudo apt-get install libapache2-svn
Svn WebDAV will be enabled by default. So you don’t need to run a2enmod. Now you should choose a directory to contains the repositories, usually some folder in /var/lib or /var/local .
$ sudo mkdir -p /var/local/svn
Then let’s create the repository, (in a folder name) bibo-project
$ sudo mkdir /var/local/svn/bibo-project
$ sudo chown www-data:www-data /var/local/svn/bibo-project
$ sudo -u www-data svnadmin create /var/local/svn/bibo-project
The chown command will ensure that the Apache user ( www-data ) can fully access the repository for reading and updating it. Now it’s time to configure the repository in Apache:
$ sudo gedit /etc/apache2/mods-available/dav_svn.conf
Add a section like this one (at the bottom of the file)
<Location /svn/bibo-project> DAV svn SVNPath /var/local/svn/bibo-project AuthType Basic AuthName "bibo Project Subversion Repository" AuthUserFile /etc/subversion/bibo-project.passwd <LimitExcept GET PROPFIND OPTIONS REPORT> Require valid-user </LimitExcept> </Location>
The above configuration not only indicating the SVN directory corresponding to the URL , but also secure the access by using Basic Authentication, i.e. username and password , which is specified in the file specified by AuthUserFile (bibo-project.passwd) . Ok, that file does not exist yet, and we’ll create it properly:
$ sudo htpasswd -c /etc/subversion/bibo-project.passwd bibo
$ sudo htpasswd /etc/subversion/bibo-project.passwd ducquoc
The -c option indicates that the password file should be created as new; and it is only necessary for the first user (here the first username is bibo, followed by ducquoc). Be aware of the fact that -c overwrites the existing password file without asking anything. Personally I think this is a quite stupid behavior, but that’s the way it is.
Now the repository should be ready, the remaining task to publish it is to restart Apache httpd like above. Or just simply reload Apache is enough:
$ sudo /etc/init.d/apache2 reload
Now, let’s test it with the browser:
If successful, you can try checking out with the svn client :
$ svn co https://localhost/svn/bibo-project bibo-project –username bibo
(of course ‘bibo’ is the username of my user, you should replace it with one of the usernames you created for the AuthUserFile )
Now verify the folder (bibo-project) which contains the working copy of our repository:
$ svn status bibo-project
Ok, now everything is ready and you can use svn commands (mkdir/add/commit/… ) on the working copy or directly to the repository:
$ svn mkdir https://localhost/svn/bibo-project/trunk –username bibo -m “created the trunk folder”
Good luck & have fun !
Pingback: SVN best practices | DucQuoc's Blog
how can you change the svn port binding to something else not port 80 ? for example:
As far as I know, the WebDAV mod of Apache exposes the SVN repositories via web protocol (HTTP/HTTPS). Thus to change it to port 8989 instead of 80, we need to modify the default port (80) in configuration file of Apache . (or modify the port of HTTPS from 443 to 8989)
Another approach also comes up in my mind: to “bridge” Apache Tomcat by mod JK (or AJP) , which is configured to serve at port 8989 . This way we can still keep original HTTP ports for Apache .
Pingback: Change Set Comments | DucQuoc's Blog
Pingback: Developer Productivity Difference | DucQuoc's Blog