Installing Apache

Apache needs to be installed and operational before PHP and MySQL can be installed, or else they won't work correctly. Any computer can be turned into a web server by installing server software and connecting the machine to the Internet, which is why you need to install Apache. To keep the installation as simple as possible, we'll address only the latest versions of Apache, PHP, and MySQL. Although you can use older versions, they're more difficult to install and get to work together.

1. Download the Apache 2.x Win32 MSI installer binary. It's downloadable from http://httpd.apache.org/. Select the "Download from a mirror" link on the left side of the page and download the best available version. A mirror is a download location. The file that you save to your desktop will be named similarly to apache_2.2.4-win32-x86-no_ssl.msi (the exact version number will vary).

If you are on Mac OS X, you already have Apache installed. Open System Preferences, select the Sharing panel, and click to activate Personal Web Sharing (which is actually Apache). Mac OS X 10.2, 10.3, and 10.4 all come with different versions of Apache, but each works perfectly fine.

2. Install Apache using the Installation Wizard. Double-click the MSI installer file on your desktop, and you see the installer shown in Figure 2-1. The Installation Wizard walks you through the installation process.

Figure 2-1. The Installation Wizard prompts you for basic configuration

3. Accept the license terms by clicking the radio button shown in Figure 2-2. Click Next.

Figure 2-2. Apache license terms and conditions for use

4. You'll see a Read This First box, as shown in Figure 2-3. Additionally, this window offers a number of excellent resources related to the web server. Click Next.

Figure 2-3. Apache HTTP Server information

5. In the dialog shown in Figure 2-4, enter all pertinent network information. Click Next.

Port 80 is the default HTTP port. In other words, when you request http://www.oreilly.com, you're implicitly requesting port 80. By accepting this port, your web requests can be made without specifying a nondefault port. Your computer's web server can always be accessed using the loopback address http://localhost or the IP address http:// 127.0.0.1. They can be used interchangeably.

6. In the next screen, shown in Figure 2-5, select the setup type. The Typical install will work for your purposes. Click Next.

7. Accept the default installation directory, as shown in Figure 2-6. Click Next.

The default installation directory, C:\Program Files\Apache Software Foundation\Apache2.2\, is both standard and easy to find, especially when you need to make changes to your configuration.

Figure 2-4. Server Network Information dialog

Figure 2-5. Selecting a setup type

Figure 2-6. Destination Folder dialog for the Apache installation files

8. As Figure 2-7 shows, it's time to begin the installation. Click Install. The installer installs a variety of modules, and you will see some DOS windows appear and disappear.

Figure 2-7. "Ready to Install" dialog

9. Click Finish when the installer is done.

10. Test your installation by entering http://localhost/ in your browser's location field. Remember, localhost is just the name that translates to the IP address 127.0.0.1, which is always the address of the local computer.

11. After entering the URL in your browser, the default Apache page displays, which is similar to the one shown in Figure 2-8. The installation was successful if you see the text "It works!" This page may be different depending on which version of Apache you install. Generally, if you see text that doesn't mention an error, the installation was successful.

Now that you can serve up web pages, you're ready to add PHP.

Figure 2-8. Apache's default index page after installation

Was this article helpful?

0 0

Post a comment