So I have finally got around to re-installing Subversion so that I can now use it for my development work. I like Subversion. I use it at work, where no-one else seems to like it, but I do. I should start using it at home now so that I can monitor all of the changes that I am making.
I have many projects, ideas and tasks that I work on simultaneously. I hope that it will help me to maintain some kind of control on what I am doing.
I currently run OSX Leopard 10.5.4, which does come with Apache 2 installed, however, I like to have the most recent version of things installed where possible. I also like things to be nice and neat, and I would rather not recompile the code if I can get away with it.
I have started using XAMPP as my main web development platform. At the time of writing this, XAMPP 0.7.2 came supplied with
- Apache 2.2.8
- MySQL 5.0.51
- PHP 4.4.8
- PHP 5.2.5
- Perl 5.10.0
- ProFTPD 1.3.0a
- phpMyAdmin 2.11.4
- OpenSSL 0.9.8e
- GD 2.0.35
- Freetype 2.3.5
- libjpeg 6b
- libpng 1.2.18
- libungif-4.1.4
- zlib 1.2.3
- expat 2.0.1
- Ming 0.3
- Webalizer 2.01-10
- pdf class 009e
- mod_perl 2.0.3
- SQLite 3.4.0
- phpSQLiteAdmin 0.2
- libiconv-1.11
- gdbm-1.8.3
- libxml-2.6.29
- libxslt-1.1.21
- openldap-2.3.36
- imap-2004g
- gettext-0.16.1
- libmcrypt-2.5.8
- mhash-0.9.9
- curl-7.16.4
- zziplib-0.10.82
- bzip2-1.0.3
- freetds-0.64
Phew, what a list.
Installing Apache
I downloaded it from this link. I also installed the Developer Package. To install the main XAMPP double click on the downloaded file xampp-macosx-0.7.2.dmg and then launch “XAMPP for MacOS X.pkg”. Follow the instructions and voila you have the enourmous list of items installed. They are installed to the folder /Applications/xampp. This means that when you are finished with it you can drop it in the bin to uninstall it. To install the Developer Package I launched the terminal and changed directory to my download folder then expanded the file with tar xvfpz xampp-macosx-0.7.2-dev.tar.gz -C /Applications.
This gave me my basic development platform now. I launched it and tested this. Running the XAMPP Control Panel (/Applications/xampp/XAMPP Control Panel.app) I was able to start all of the processes and then opening a browser and visiting http://localhost/ I could see that everything was working as I expected.
At this point, they advise you to secure your installation by setting the passwords and stuff. You can follow this information on the apachefriends site.
Installing Subversion
This installation does not come with Subversion installed. I downloaded this from openCollabNet to download the Universal Binary installation for Subversion 1.50. This includes the binaries for Apache 2.2. Running the disk image Subversion 1.5.0 Universal.dmg and launching the contained Subversion-1.5.0.pkg. This installs everything to the default location in /opt/subversion, backing up any version which was originally there. This also links various executable files to /usr/local/bin folder. Typing ‘svn --version‘ from the terminal will confirm that this is installed correctly.
Configure Subversion
The next step is to create the basic repository. My repository is to be located at /Volumes/Data/Repository. Launch the terminal and type the following:
sudo su
svnadmin create /Volumes/Data/Repository
chown -R nobody:wheel /Volumes/Data/Repository
cd /tmp
svn co file:///Volumes/Data/Repository/
cd Repository
svn mkdir trunk branches tags
svn commit -m "initial import"
exit
This will create a basic Subversion structure for all of your future projects
Configuring Apache
As we are going to use Apache to run Subversion server we now need to configure Apache. This requires the configuring of the Subversion modules within Apache. These modules are mod_authz_svn.so and mod_dav_svn.so. Apache would usually expect to find these within its modules directory. This is currently located at /Applications/xampp/xamppfiles/modules. The installation of Subversion puts these files at /opt/subversion/lib/svn-apache. We can copy (or move) these files to the right location, but I would rather create a link.
sudo su
cd /Applications/xampp/xamppfiles/modules
ln -s /opt/subversion/lib/svn-apache/mod_authz_svn.so mod_authz_svn.so
ln -s /opt/subversion/lib/svn-apache/mod_dav_svn.so mod_dav_svn.so
exit
Next we add the libraries to Apache. Edit the httpd.conf and add the following lines to type LoadModules section of the file:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
Also, I uncommented the following lines from the end of the file
Include /Applications/xampp/etc/extra/httpd-vhosts.conf
Include /Applications/xampp/etc/extra/httpd-dav.conf
This will allow us to store the DAV and Virtual Hosts settings in separate files. These files will be in the ‘extra’ subdirectory.
Add the following to your httpd-vhosts.conf file
<VirtualHost *:80>
ServerName svn.xetius.local
<Location />
DAV svn
SVNPath /Volumes/Data/Repository
</Location>
</VirtualHost>
All that remains now is to add this entry to your hosts file (svn.xetius.local for me) and restart the apache server. Now, if I go to http://svn.xetius.local/ I will see my repository.
Setting Security
If you need to add security to your Subversion configuration you will need to set an authorisation file. To do this, go to the terminal and do the following:
sudo htpasswd -c /Applications/xampp/etc/svn-auth-file chris
Enter Password
Confirm Password
Now add the following lines to the Location section we added earlier to the httpd-vhosts.conf file
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile "/Applications/xampp/etc/svn-auth-file"
Require valid-user
We should now have Subversion working on Apache. I hope this helps someone. I am going to try to get this working over a secure connection (SSL) next to make this a little more secure.