This guide will walk you through creating a subversion server source control repository which can be used to version files (source code, documents, etc, etc). You can browse the repository with Mozilla FireFox, Google Chrome, etc. We will install the svn server on a Ubuntu v9.10 (Minimal System) Linux server. Our end users are developers using Windows XP, Windows Vista, and Windows 7.
Part 1: Apache-SVN Server Installation
The steps in the following section are performed on a newly installed Ubuntu 9.10 Minimal Server installation.
STEP 1: Setup Static IP Address
# Backup network settings
$ sudo cp /etc/network/interfaces /etc/network/interfaces.old
$ sudo nano /etc/network/interfaces
# Edit network config. Edit lines:
auto eth0
iface eth0 inet dhcp
# and change them to (something like) the following:
auto eth0
iface eth0 inet static
address 192.168.2.[PickANumberFrom1to254]
netmask 255.255.255.0
gateway 192.168.2.252
broadcast 192.168.2.255
# Save the file, and then restart networking:
$ sudo /etc/init.d/networking restart
STEP 2: Install Apache & Subversion Servers
$ sudo apt-get install apache2 libapache2-svn subversion subversion-tools
STEP 3: Create Source Code Store
The folder you create here is the physical location the code is stored on the server. I have a backup hard disk (/dev/sdb) mounted on /home, so I have created my repository in this location.
$ sudo mkdir -p /home/svn/repo
STEP 4: Configure Apache SVN Module
This step can be a bit tricky. Be sure you restart apache after making these changes. If Apache throws an error restarting then you have not done this correctly.
$ sudo nano /etc/apache2/mods-available/dav_svn.conf
# Uncomment these settings:
<Location /svn>
DAV svn
SVNParentPath /home/svn/repo
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
# Add this line directly below the line above (require login for read & write)
Require valid–user
</Location>
STEP 5: Create Users
This step is for adding web users to the system. NOTE: be sure to only use the -c switch for the first user, to prevent the file from being written over each time you add a user.
$ sudo htpasswd -cm /etc/apache2/dav_svn.passwd firstUser
$ sudo htpasswd -m /etc/apache2/dav_svn.passwd secondUser
STEP 6: Create Initial Repostiory
Next, we are going to create our first repository and assign the correct permissions for it.
# Create initial repository:
$ sudo svnadmin create /home/svn/repo/<repoName>
# Assign Ownership to Apache (so we can write to it from the http)
$ sudo chown www–data:www–data –R /home/svn/repo/<repoName>
$ sudo chmod –R 770 /home/svn/repo/<repoName>
STEP 7: Port Assignment/Validation
If you run more than one web server but only have a single internet IP address then you may wish to change the IP address that Apache listens on so your router can forward apache traffic into the network on a port other than 80. Below are the steps for configuring Apache to listen on port 8888:
# Assign Port (if needed)
$ sudo /etc/apache2/ports.conf
# Add this line below Listen 80:
Listen 8888
Restart Apache: to apply all the changes in Steps 1-7, you must restart Apache:
$ sudo /etc/init.d/apache2 restart
Apache should now be setup and working. To test it navigate to: http://ServerIPAddress/svn/<repoName>
Part 2: Using Subversion in Windows
The steps in the following section are performed on a windows workstation which will use our apache-svn server for source control.
STEP 1: Install subversion client
Download and install the TortoiseSVN client application. You will be required to reboot. Following the reboot you will notice a new set of right click shell links in your context menu for tortioseSVN.
STEP 2: Create/Get Source Controlled Folder
I typically have 2 primary directories under source control in the Visual Studio 2008/Projects directory; TFS and SVN. Team Foundation Server projects are stored in the TFS\<projectName> folder and Subversion projects are stored in the SVN\<repoName> folder.
- Create a new folder: <repoName> which will store all of your SVN-controlled code files.
- Right-click on the <repoName> folder and select SVNCheckout.
- Enter the path to your repository (e.g. http://ServerIpAddress/svn/<repoName>). This will sync the client and workstation.
Create 3 new folders within your <repoName> folder. Call these folders: branches, tags, and trunk. Copy all the files you want to version into the trunk folder.
You are now ready to begin committing code to the repository, unless you are using Windows 7 (or you have the enhanced Indexing Service installed through Microsoft Update).
STEP 3: Fix Windows 7 x64 Indexing Bug (which causes reporitory fs corruption)
If you try to commit or update to the repository in Windows 7 you will likely get this error:
Can't move '.svn/tmp/entries' to '.svn/entries': The file or directory is corrupted and unreadable.
This is due to the Microsoft Windows Indexing Service attempting to seize a handle to the files subversion is controlling in it's internal/hidden .svn directories. To fix this bug you have to either wait for Windows 7 SP1, or disable the Indexing Service for the folder containing your SVN files (see below)
- Click the start menu button, then click in the 'Search programs and files' text box
- Type in “windows index”.
- Click on “Indexing Options” that should come up in the search.
- When the Indexing Options box comes up, Click on the Modify button.
- In the indexed locations dialog box, uncheck the root folder where subversion is managing files.
Bug info: http://tortoisesvn.tigris.org/faq.html#cantmove2
Bug info: http://serverfault.com/questions/72561/64-bit-tortoisesvn-on-windows-7-says-file-or-directory-is-corrupted-and-unreadab
STEP 4: Set MIME-TYPE and Commit Code
If you do not plan on viewing your checked-in source code directly within you web browser you can skip to comitting your code into subversion. If you do plan on allowing users to view versioned code directly in the web browser then you will have to set the MIME-TYPE property on each file you wish for apache to serve up as plain-text. If you do not do this then the directory structure will be viewble but any file you click will bring up a download dialog box.
Set the MIME-TYPE property to text/plain
In our sample, we are checking in a collection of shared scripts. We want to view these scripts directly in the browser, so we need to set the mime-type on all of them. To do this we perform a search in windows to list all *.vbs files in our <repoName> folder. When the search is complete, we highlight all the files and right click > TortoiseSVN > Properties.

In the properties dialog box select the property name: svn:mime-type and enter text/plain.

Commit the code to Subversion
Finally, we are ready to commit our code to subversion. to do this, all you have to do is right-click on the <repoName> root folder and select SVNCommit.
