Part 1 of this text is going to walk you through installing and configuring the Apache Web server in preparation for hooking Apache and Subversion together.
Advantages of Using the Apache Web Server
Apache is not required in order to run Subversion. Subversion includes it's own standalone server, called svnserve, that allows you to deploy and utilize Subversion repositories. The standalone server works just fine and can be installed on just about any operating system out there (Windows, *nix, and Mac OS X). Svnserve offers deployment as an inetd service, a daemon service, offers basic authentication and authorization, can be utilized over an internal network, and can be tunneled over ssh for security. So why integrate Subversion and Apache?
There are several advantages to using Apache especially if your team is already running the Apache Web server. First and foremost, your Subversion repositories have more reach, and are available wherever your Apache Web server is available. Depending on your network configuration this may mean expanded availability for remote developers or developers that need to work from home for a day (ever waited 4 hours for the cable guy?) Another great benefit is enhanced repository access logging through Apache's built-in logging mechanisms, and since we're using HTTP, that means we can also make use of HTTPS for encrypted repository access over SSL. As if that weren't enough you gain built-in repository browsing through your Web browser of choice. Given all the benefits of Apache, you may be wondering why anyone would use the built-in svnserve Subversion server. The answer, is simplicity: it's really easy to set up and configure svnserve while a bit more complex to set up and configure repository access through Apache. Hopefully, this text will make the latter much less painful for you.
First things first, you need to download Apache. For the purposes of this text all references to and illustrations of Apache are of version 2.0.59. However, as long as you are working with 2.x all instructions herein should be accurate. To get Apache, point your Web browser to http://httpd.apache.org/download.cgi. This page offers 2.2.x as well as (at the time of this writing) 2.0.59. Since this text focuses on setting up a Windows server with Apache, you'll want to download the Win32 Binary which should look something like: apache_2.0.59-win32-x86-no_ssl.msi.
To begin installing Apache you'll need to find and double-click the *.msi file you downloaded earlier. You might also want to think about where you are installing Apache. All the screen shots referenced in this section refer to a development server installation. This is the most common practice on small to large teams but if you're an individual developer you may be installing everything on your personal machine. Either way, the process is the same; just be aware of the machine differences as you walk through the server installations (Apache, Subversion, and TortoiseSVN) and the client installations (TortoiseSVN and Subclipse).
Figure 1: Begin Apache Installation
Once the initial Apache installation screen displays, press Next to continue.
Figure 2: Configure Basic Apache Settings
In this screen you'll configure some basic settings for your Apache server. If you are installing Apache on a development server you will likely use some sort of company or personal domain. If you are installing Apache on an individual development computer you will probably use 127.0.0.1 for both the Network Domain and the Server Name. Just remember what you put here, because all work from now on will use these initial settings. If you follow my example to the strictest detail (as will the rest of this text) you will need to ensure the Network Domain you enter points to your development server. This is accomplished - most often - with DNS entries on your corporate network. If these entries are not in place you can edit your personal computer's hosts file to point the yourcompany.com and/or svn.yourcompany.com domains to your development server. One last note, leave the radio button set to All Users, on Port 80 for now. I'll demonstrate how to change this later in order to provide a very singularly-focused Apache/Subversion installation.
Figure 3: Custom Setup Screen
The Custom Setup screen is designed to show you specifics regarding what Apache will be installing and where. All of the default installation settings are fine for the purposes of this text.
Figure 4: Ready to Install Apache
You're now ready to install Apache. Press the Install button and relax for a few seconds.
Figure 5: Apache Successfully Installed
Once the installation has finished your screen should look similar to that of Figure 5. At this point, Apache is installed and configured to run on port 80 (the default port). If you already had a Web server (like Microsoft's Internet Information Server) running on port 80 Apache may not be running. As part of this text I will be configuring Apache to run on port 81 as a dedicated Subversion Web server. This is a requirement in my development environment as IIS is already running on port 80. Thus, all examples and screen shots from here on will have port 81 in them, but, let's not get ahead ourselves. Before making this change let's get familiar with three important pieces of the Apache Web server: the htdocs (webroot) directory, the conf (configuration) directory, and the Apache Monitor.
Figure 6: The Apache Web Root Directory
By default, Apache is installed to C:\Program Files\Apache Group\Apache2. Apache's Web root is, by default, located in the htdocs directory. The files shown in Figure 6 are all that is needed for Apache's test page (which we will be viewing shortly) to function properly. All other files are for internationalization and can be safely removed.
Figure 7: The Apache Configuration Directory
Apache's configuration is determined by the settings in the httpd.conf file. For convenience and safe keeping Apache has already created a backup of this file for you (httpd.default.conf). Should you ever mess something up in the httpd.conf file you can always revert back to the original, factory settings, by making a copy of httpd.default.conf and naming the copy httpd.conf. It's also a good idea to make a habit of backing up your httpd.conf file just before making major changes. I'll be directing you to make numerous changes to the configuration file as we progress through the various parts of this text. For now, let's take a look at the Apache Monitor.
Figure 8: Accessing the Apache Monitor from the System Tray
The quickest and easiest way to view the Apache Monitor is to right-click the Apache icon in the system tray and select Open Apache Monitor.
Figure 9: The Apache Service Monitor
The Apache Service Monitor (or Apache Monitor for short) is your central location for starting and stopping the Apache Web service. I'll reference the Apache Monitor extensively as we move through this text. Now that we've gotten familiar with the htdocs directory, the conf directory, and the Apache Monitor, let's make one or two changes before we test Apache to make sure it's working properly.
Changing Apache's Listen Port
Figure 10: Editing the Apache Listen Port
Earlier I mentioned my development team server runs Internet Information Server on port 80. Because of this, I must run Apache on a different port. Port 81 is a nice alternative and will allow my Apache Web server to run alongside of IIS. You don't have to perform this step but all screen shots and references to Apache will include use of port 81. Perform all subsequent steps based on your configuration. To change the listen port you'll need to stop Apache using the Apache Monitor. Then, navigate to Apache's configuration folder (Figure 7) and open the httpd.conf configuration file (Notepad works great), find the Listen 80 text and change it to read Listen 81.
Figure 11: Setting Apache's ServerName
Since I've changed the port Apache is listening to I want to make sure Apache's ServerName reflects the same information. Doing this is completely optional but I like having all places that display the ServerName remind me of the configuration. To change the ServerName, find the appropriate line in the httpd.conf configuration file and change it so it matches Figure 11 above. Make sure you save your changes and start Apache using the Apache Monitor. If there are any problems with what you've changed, the Apache Monitor will be happy to notify you when you try and start up the server. If you do experience problems, double-check your work and the screen shots above and try restarting Apache again.
Figure 12: Testing Apache
With Apache up and running and after altering the Listen Port and ServerName, it's time to test our changes. Open your Web browser and point it to svn.yourcompany.com:81 replacing "yourcompany" with the domain you entered during the installation of Apache (Figure 2). If all goes well you should see a display exactly like Figure 12 above. If the page comes up but doesn't look quite right, it's possible you removed too many files from the htdocs directory (Figure 6). Verify your htdocs directory has at least those files in Figure 6 and reload the page. If you get an error indicating there's no Web server running or the Web server can't be found you need to make sure the domain you entered during installation (Figure 2) is pointing to your server's IP address.
Let's review our work. We started by installing Apache using all the default settings. I then discussed the Apache htdocs and conf directories and the Apache Services Monitor. Next, we made a few changes to our Apache configuration (httpd.conf) directing Apache to listen to port 81 instead of port 80. We also changed the Apache ServerName so that it indicates Apache is listening to port 81 instead of the default. Last but certainly not least, we tested our new Apache Web server by loading its default page in a Web browser. With all of this out of the way, it's time to install Subversion and integrate it with Apache!
5 related blog entries
- Part 5: Accessing Subversion Repositories With Subclipse (March 15, 2007)
- Part 4: Subversion and Apache - Better Logging and Authenticated Access (March 14, 2007)
- Part 3: Installing TortoiseSVN 1.4.3 and Creating Your First Repository (March 14, 2007)
- Part 2: Installing Subversion 1.4.2 and Integrating Subversion With Apache (March 13, 2007)
- Configuring a Development Environment with Apache, Subversion, TortoiseSVN, and Subclipse (March 12, 2007)