VerySimple Developer Blog
Technical Tips, Tricks and Rants.
 
Mar
30
Filed Under (Apache, SVN, Windows) by Jason on 30-03-2006

How to Install Subversion Server on Windows using Apache

This is a walkthrough to install subversion server on Windows and make it available over http using Apache. Subversion is a version control system. In combination with Apache, you can allow local and remote developers to share source code.

This guide will use the following installation paths. You can change these as you like, but I’m going to use them in this walkthrough:

Apache = C:\Program Files\Apache Group\Apache2
Subversion = C:\Program Files\Subersion
Location of Repositories: C:\InetPub\svn\
Location of passfile: C:\InetPub\svn.pass
URL for Repositories: [url]http://localhost:8080/svn/[/url]

1. INSTALL APACHE

a. Download Apache from http://httpd.apache.org/download.cgi (Apache 2.0.55 is the current stable release at the time of this writing)

b. Run the Windows Installer. The defaults are fine. When you reach the Server Information dialog, you’ll be prompted to choose between installing on port 80 as a service, or on port 8080 with manual startup. Choose the service option on port 80 (we will change the port in the next step). Complete the install process accepting all defaults.

c. Since we are working on a Windows server, you probably already have IIS running on port 80. So, we need to pick another for Apache - this is really easy to change. Open the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf in notepad.exe. Do a find (ctrl+f) for the word “listen” until you fine the line

Listen 80

Change the 80 to 8080 (or whatever port you want). For this example, I’m going to be using port 8080

d. Save http.conf and restart Apache to reflect the changes. You can do this through the services applet (Start -> Run services.msc) or also through the apache service monitor (This is the apache icon next to the clock in the taskbar)

e. Test that Apache is running by going to [url]http://localhost:8080/[/url] (you should get the default Apache welcome screen).

2. INSTALL SUBVERSION

a. Download The subervsion server binary for Windows. It’s currently located at http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
For these instructions, download the svn-x.x.x-setup.exe installer.

b. Run the Subversion server setup. All defaults are fine. At a certain point you’ll see an option about installing Apache Modules. As far as I can tell this does nothing, but whatever! I left it checked.

3. CONFIGURE APACHE SUBVERSION MODULES

a. We need to move the subversion modules so Apache can use the. To do that, copy the following files from C:\Program Files\Subversion\bin\ to C:\Program Files\Apache Group\Apache2\modules\

libdb42.dll
libeay32.dll
mod_authz_svn.so
mod_dav_svn.so

b. Open C:\Program Files\Apache Group\Apache2\conf\httpd.conf again and do a find for “LoadModule” - This should take you to a section where there are a bunch of LoadModule statements uncomment this line (delete the # from the beginning of the line):

LoadModule dav_fs_module modules/mod_dav_fs.so

Below that, add the following two lines:

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

Now scroll to the very botton of the file and paste the following.

<Location /svn>
DAV svn
SVNParentPath C:\InetPub\svn
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile C:\InetPub\svn.pass
#AuthzSVNAccessFile svnaccessfile
Require valid-user
</Location>

You can change these as you like, however this is what I’ll use for the instructions here. I happen to think these are reasonable defaults. The settings are probably somewhat self-explainitory, but for additional information read the fine Apache manual.

c. Restart Apache Again to load the configuration changes

d. Test that everything is working at this stage by going to [url]http://localhost:8080/svn/[/url] You should get prompted for login box. We haven’t created a username/password yet so just hit cancel.

4. CREATE A USERNAME/PASSWORD FOR HE APACHE DIRECTORY

a. We need to use htpasswd.exe in the Apache2/bin directory to edit the password files. this is a pain unless it is in your path, so I recommend adding it to your environmental PATH variable. (right-click My Computer -> Advanced -> Environmental Variables) Append the folling to the PATH variable: ;C:\Program Files\Apache Group\Apache2\bin

b. Create a blank file C:\InetPub\svn.pass

c. Open a new DOS windows (you need to open a new one to recognize the PATH changes)

d. go to C:\InetPub and type the following:

htpasswd snv.pass svnuser

You’ll be prompted for a password. enter whatever you want (svnpass for this example)

(This is the procedure you can repeat to add more users)

e. You can open svn.pass in notepad to make sure there is a user there - you should see “svnuser” followed by the crypted pass information.

5. CREATE A REPOSITORY

a. Open Windows explorer and create a folder C:\InetPub\svn

b. Open a DOS window and go to C:\InetPub\svn

c. Enter the following:

svnadmin create myrepository

(You can repeat this process to create additional repositories - I am just choosing the name myrepository for testing purposes)

d. Give it a test by opening [url]http://localhost:8080/svn/myrepository/[/url] and entering the username/pass you created in step 4 (in this example svnuser / svnpass) If everything is working right, then you should see “Revision 0″ in the browser.

Contratulations - You’re Done!

6. USING YOUR REPOSITORY

If you need instructions for using subversion, I’d recommend downloading TortoiseSVN from http://tortoisesvn.tigris.org/ and reading the documentation. Although setting up the server is a bit of work, using the client is pretty easy.

When you use your client to connect to the server, your subversion repository will always start with http://your.domain.com/svn/ (as opposed to some public repositories that start with svn://your.domain.com/) Otherwise, the usage is exactly the same.

If you haven’t managed a Subversion server, you may not know how to initialize your repository. Basically, each time you create a new repository, you have to initialize it by doing an import. You have to add at least one file to the repository. To do this, just create a blank folder on your computer, put at least 1 file in there (I put a readme.txt or whatever). Then use your subversion client “import” command. This will initialize the repository at version 1. At that point, you can check in and out as you always do.

THE END

 

Comments:
6 Comments posted on "Install Apache + Subversion on Windows"
King Wilder on September 1st, 2007 at 6:47 pm #

I want to thank you for this Blog post. I have been pulling my hair out for days trying to figure out how Subversion works and how to get it installed correctly.

With the help of you blog, I have finally got it to work on my local network so I can easily work between my various client machines.

Thanks again,

King Wilder


King Wilder on September 1st, 2007 at 7:13 pm #

I’m coming from using Microsoft Visual Source Safe for source control. But I’m working between a few computers in my office and some with Windows Vista and I can’t install VSS 6.0d.

So I have a question, just so I know how to use Subversion correctly.

I build an ASP.NET application on my development laptop, when I’m done for the day, I close the project and Visual Studio, then open Windows Exploer and I use TortoiseSVN.

I right-click on the folder for my .Net project and select the TortoiseSVN > Import command. Then I import to my server (a separate machine) in the project repository.

Do I need to delete the Project folder and its contents? Scary…

Then when I want to work on it I create a folder location on my local laptop where I want to checkout my project files, and I right-click the folder, select TortoiseSVN > Checkout and find the repository project and click OK.

The part I’m not clear on is what I do with the project folder I just worked on. Does everybody who works with SVN checkout a project to a new folder and then delete the folder when they are done?

Thanks,
King


King Wilder on September 1st, 2007 at 7:15 pm #

Also, re: your blog, there seems to be some CSS or HTML codes surrounding your code examples that I was confused about at first.

My email is info@kingwilder.com.

King


Jason on September 2nd, 2007 at 1:07 am #

Hey King,

Switching from VSS to SVN can be a little weird at first because SVN uses what is called optimistic version control. Unlike VSS you never actually check out a file and lock it from others using it.

As far as using it with .NET apps - one thing with dot net is to make sure to configure the “.NET Hack” otherwise for some reason visual studio will complain. Also you need to do this prior to checking out projects. Or if you do, you’ll have to re-check out your projects.

Something that is actually really nice about SVN, unlike VSS is that you don’t have to have a single dedicated “working folder” for your app. Basically you can just create a folder anywhere and do a checkout. So, don’t really need to worry about wiping out anything. You can just create a temp folder, do an update and see if it looks ok.

There’s also an SVN plugin for visual studio http://ankhsvn.tigris.org/ but I think actually the explorer interface is easier to use.


King Wilder on September 2nd, 2007 at 12:18 pm #

Jason, this has been a little bit of a learning curve, but I’m starting to warm up to it.
The thing I liked about VSS was that I essentially had two things to do, checkout the latest source code, and then check it in. I didn’t need to know about building servers for this to run in or anything like that.
The bad thing about that version of VSS, was that I think it was only for a single machine (I really don’t know). But that’s how I used it and it would have been nice to be able to make the code available to other workstations in my office.
Tell me I understand this correctly, once I check out the first copy, I can keep it there and simply, “commit” changes, and then check for “update”s to my working folder. I don’t need to wipe out my folder once it’s first checked out, is that correct??
I heard about the .Net Hack and I’ll look into setting it. I don’t know what the difference is for .Net apps, it would seem, code is code.
I looked into the SVN Visual Studio plug-in ankhsvn, but ToroiseSVN gives me the ability to manage some straight HTML sites that I build for clients as well as ASP.NET or Windows .Net apps.


Jason on September 6th, 2007 at 11:54 am #

Hey King - You are right, you don’t need to wipe out anything once your repository it setup. What is more, the project is not really tied to any specific folder so you can move it all around or whatever unlike VSS which wants the working folder in a set location. You’ll notice your project have a hidden folder in them “.svn” (or “_svn” if you have the .NET hack). SVN keeps all the internal information in this folder and so it’s portable - you can move it around, make a copy, etc. You’re not locked into having a working folder in one location. This is highly convenient for branching too.

Also, you are right about VSS that you were set up as a single-user. You can actually open it up for other users by sharing your VSS database file, but VSS has never been really easy for sharing with people that are not on your local LAN. Becasuse it relies on windows file sharing, you basically have to set up a VPN to let remote people access the repository.

If you don’t have the .NET hack on and you are doing .NET development, I’d definitely recommend you set that before going any further. Visual studio for whatever reason does not like the folder “.svn” inside a .NET project and it will sometimes crash when parsing the project.


Post a comment

Name: 
Email: 
URL: 
Comments: 
Close
  • Social Web

NOTE: Email is disabled

E-mail It