Mar
12

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.

Downloading Apache

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.

Installing Apache

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.

Apache Basics


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.

Summary

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!

Aaron West's Gravatar
About this post:

This entry was posted by Aaron West on March 12, 2007 at 10:48 PM. It was filed in the following categories: ColdFusion, Apache, Subversion. It has been viewed 43958 times and has 10 comments.

5 related blog entries

10 Responses to Part 1: Installing and Configuring Apache 2.0.59

  1. David Lakein

    FYI, there may be a difficulty using Apache 2.2 instead of 2.0. According to the Subversion download site, the Windows Apache modules provided there right now are compiled against Apache 2.0, and won't run on Apache 2.2. Requires a recompile of the module code, with some other libraries.

  2. David, that's correct. Plus, my instructions regarding Virtual Hosts are not directly applicable to how Virtual Hosts are set up with Apache 2.2.x as they have changed in the new version of Apache.

    For now, I recommend folks stick with the 2.0.x build.

  3. Carlo Orellano

    Hi there,
    I installed apache in my machine and it is running perfectly even when I put my
    web address and it shows the default page. However, I want to change that default page with my own web-page when I type my web address. any suggestion? Thanks I appreciate it,
    Carlo

  4. Hi Carlo,

    If you want to serve your own pages from where the current default page shows all you need to do is put your content in the same location as the default pages. This location is typically C:\Program Files\Apache Group\Apache2\htdocs\ on Windows and /usr/local/Apache/htdocs/ on Mac. If you chose options other than the default during the installation process these directories may vary.

  5. Luis Diaz

    Is there a noticeable performance difference between svnserve and an Apache implementation?

  6. It depends Luis. For normal updates and commits I personally have not noticed a performance difference. However, the cost of checking out an entire working copy of a repository can take longer via Apache than svnserve. I've only noticed a difference on large repositories that are several GB's in size.

    If you were to access your repositories over Apache/SSL I think you'd see a further degrade in performance due to the encryption. It's like everything else in the world, you have to pick what's more important to you (or your team): speed (svnserve) or accessibility over the Web, security (SSL) or a faster vanilla HTTP connection.

    Performance was probably the last thing on my mind when building out our development environment at the office. All the benefits of using Apache quickly rose to the surface.

  7. Troy

    I just installed Apache following your instructions. Very easy, indeed.

    I am having problems when pointing to http://localhost/cgi-bin/printenv.pl - I get 500 Internal Server Error.

    When I go to command prompt and change directory to C:\Perl\cgi-bin\ and type perl printenv.pl I get response, but not with the browser http://localhost/cgi-bin/printenv.pl

    WHY?

  8. dc

    hi,
    I've got a project started on sourceforge .
    I'm unsure though still as to what to put in the apache setup for the network domain and server domain .
    can you help ?

  9. Mario da Silva

    Thanks for a very easy read! This is my first attempt at a personal Apache server at home, trying to set up some lecture notes for my students. I did everything in your instructions and registered a DYNDNS name too. I must still be missing something, 'cause at the browser I still get SERVER NOT FOUND, even fiddling with the Router settings for two days running ... no joy. I must have missed something.

  10. @Mario - What happens when you ping the URL you are using? If you have the URL set up right in DNS or your computers host file the IP address returned by the ping should be 127.0.0.1 or the IP address of the server running Apache. Is this much working properly? I'm guessing that it isn't given the error you mentioned.