Team LiB
Previous Section Next Section

Installing Apache for Windows

Installing Apache for Windows is a simple task, due in great part to the installation wizard distributed by the Apache Group. Whether you're using Windows 95, 98, Me, 2000, XP, or NT, the installation process of the precompiled binaries is definitely the way to go, and the same installation file is used for all flavors of Windows.

Being able to use Apache on consumer-oriented operating systems such as Windows 95/98/Me/XP doesn't mean that you should, at least not in a production environment. Simply put, running any web server on a Windows operating system is not as fast, stable, or secure as running a web server on a Linux/Unix machine. However, installing and configuring a development web server on a Windows-based operating system is perfectly acceptable, and is how most users get their start.

Note 

The Apache Group also distributes the source code for Apache on Windows, should you have a need to compile the code yourself. However, that process is well beyond the scope of this book!

To download the Apache distribution for Windows, start at the Apache Server website, http://httpd.apache.org/, and follow the Download link. Before going any further, be sure to follow the link in the sentence, "If you are downloading the Win32 distribution, please read these important notes." (The actual link depends on the mirror you are using.)

When you've determined your system is stable enough to continue, look for the bulleted item on the page for Win32 Binary (MSI Installer), followed by a link to the software.

Distribution files follow a naming convention, with apache followed by the version number, and then -win32-x86-no_ssl.msi. As of this writing, the current version is 2.0.49, so the file used as an example throughout this section is apache_2.0.49- win32-x86-no_ssl.msi. Once you have downloaded the installation file to your hard drive, the following steps will take you through the installation wizard:

  1. Double-click the file called apache_2.0.49-win32-x86-no_ssl.msi. The installer will start, and the installation wizard will begin. Click on Next to continue.

    Click To expand
  2. Read the licensing information on the screen, choose the I Accept radio button, and then click on Next.

  3. Read the general Apache information on the screen, and then click on Next.

  4. The next screen requires you to fill in some details about your server: the network domain, the server name, and the administrator's e-mail address.

    Click To expand
    Note 

    If you do not know the network domain or server name at this point, enter some dummy information so that the installation moves forward. You will learn how to edit this information post-installation, so no matter what you enter in this step, you will soon be able to fix it. If you do know your domain and server name, go ahead and enter it.

  5. Choose the Run as Service for All Users radio button and click Next.

  6. Choose the Typical set-up type, and click on Next.

  7. Accept the default destination folder and then click on Next.

    Note 

    If you elect to change the destination folder for the Apache installation files, please adjust the instructions and paths accordingly throughout this book.

  8. Choose Install on the next screen, and the final installation sequence will begin. When the sequence is finished, you will see the confirmation screen. Click on Finish to complete the installation and close the installer.

    Click To expand

At this point, all of the necessary Apache files are installed, as well as a group of handy shortcuts in your Windows Start menu, called Apache HTTP Server 2.0.49. To run a basic test before moving forward to configuring your server, choose Program Files, Apache HTTP Server 2.0.49, Configure Apache Server, Test Configuration from the Windows Start menu. This will launch a console window showing a successful installation.

If you have any errors at this point, rerun the installation program. In the next section, you make some minor changes to the Apache configuration file before you start Apache for the first time.

Click To expand

Configuring Apache on Windows

To run a basic installation of Apache, the only changes you need to make are to the server name, which you might already have done during the installation wizard. However, if you entered dummy information for the server name, or want to modify any other part of the basic configuration, now is the time to do so.

The master configuration file for Apache is called httpd.conf, and it lives in the conf directory, within the Apache installation directory. So if your installation directory is C:\Program Files\Apache Group\Apache2\, the httpd.conf file will be in C:\Program Files\Apache Group\Apache2\conf\.

Again with the handy shortcut, you can quickly access this file by selecting Program Files, Apache HTTP Server 2.0.49, Configure Apache Server, Edit the Apache httpd.conf Configuration File from the Windows Start menu. This shortcut is the same as opening a text editor and navigating to the file location. To modify the basic configuration, primarily the server name, look for a heading called Section 2: 'Main' server configuration. You will find two important sections of text.

  1. Change the value of ServerAdmin to your e-mail address, if it isn't already accurate.

  2. Change the value of ServerName to something accurate, if it's isn't already.

  3. Save the file.

    Click To expand

The ServerName modification is the most important change you'll make to your Apache configuration file, because if the ServerName isn't correct, you won't be able to connect to Apache. As it states in the configuration file itself, "You cannot just invent host names and hope they work." If you do not know your full machine name, you can use an IP number. If you have a static IP number (that is, one that does not change), use it as your ServerName. If you have a dial-up connection that does not assign a static IP (that is, your IP number changes each time you connect to your Internet service provider), you will have to change the IP number in httpd.conf each time you dial up.

Tip 

The ServerName changes described here are relevant only if you want people from the outside world to be able to connect to your new web server. If you are the only person who will be accessing the server, you can use the IP number 127.0.0.1, which is recognized by machines as the local loop-back address, also known as localhost. You can use either the word localhost or the IP number 127.0.0.1 as ServerName in httpd.conf. The IP number will probably work out better, because some Windows machines do not automatically know that localhost equals 127.0.0.1.

Once the appropriate modifications are made to the httpd.conf file, Apache is ready to run on your machine. In the next section, you start and connect to Apache.

Starting and Connecting to Apache

To start the Apache server, select Program Files, Apache HTTP Server 2.0.49, Control Apache Server, Start from the Windows Start menu. This will launch a console window, which will then close. Apache will be running in the background.

With your web server running, you can connect to the server via your web browser of choice. The URL will be whatever you used as ServerName—an actual name or IP, localhost, or 127.0.0.1.

Note 

Remember, only you can connect to your web server using 127.0.0.1 or the name localhost. This book assumes that you'll be using 127.0.0.1 as the ServerName, so if you are not, just substitute your machine name for 127.0.0.1 in the examples.

To finally test your installation, open your web browser, type http://127.0.0.1/ in the location bar, and press Enter. You should see a default web page.

Click To expand

This default start page comes from the htdocs directory within your Apache installation directory. You can go into that directory and delete all the default files if you want to, or you can leave them. They're not hurting anything, but you'll eventually be filling the htdocs directory with your own files and subdirectories, so you might want to delete them now for the sake of good housekeeping.

Move ahead to the next chapter, where you install PHP and make a few more minor changes to your Apache configuration files before you're ready for some action.


Team LiB
Previous Section Next Section