Even though my "live" websites, like thesitewizard.com, are located on third party web hosts, I maintain an Apache web server on my Windows machine. Why?
I find it very inconvenient to have to go online just to test and debug my PHP scripts. If you write CGI and PHP scripts, you might be in the same boat.
Although I do have Apache and PHP installed in my Linux box, it is a real hassle to keep having to reboot in order to test my scripts, since I spend most of my time in Windows.
If you are facing a similar situation, or want to set up Apache in Windows for some other reason, you might find the information here useful.
Important: Note that this article deals with the setting up of Apache 1.x on Windows. If you are looking for information on how to set up Apache 2 on Windows, please see my other article How to Install and Configure Apache 2 on Windows instead. And if you use Windows Vista, please read the How to Install Apache 2.2 on Windows Vista tutorial. Vista requires different steps for a successful installation.
If you are using Windows 95 (whether the original release or OSR1, OSR2, 2.1 or 2.5), you will need to install Winsock 2 first. (Skip this section if you're using a later version of Windows).
Get both WS2SETUP.EXE (Winsock 2) and the Y2K fix for that (Y2KVDHCP.EXE) from the Windows 95 download page on Microsoft's website.
Go to the link for the Y2K fix for Winsock 2 and DUN 1.3 (or later) and follow it. It'll lead you to a page with both the fix as well as the complete Winsock 2 package.
Note that Winsock 2 requires you to have DCOM version 812 or higher installed. If you don't have that, download it (free of charge) from Microsoft and install it.
If, like me, you hate to install anything on your Windows machine that will affect the fragile balance it currently operates under, here are some (hopefully) reassuring news:
You do not have to install DUN 1.3 just to install Winsock 2. The two are separate. The Y2K fix listed above will not install any DUN 1.3 if you do not currently have it. (DUN 1.3 has been reported to cause problems on a number of Windows 95 machines.)
Winsock 2 can apparently be uninstalled, and your original Winsock 1.1 will be restored. Your old Winsock files are copied to C:\WINDOWS\WS2BAKUP together with a batch file named WS2BAKUP.BAT which can be used to restore your Winsock 1.1 if your upgrade fails for some reason.
If you are thinking of allowing others on the Internet to access your web server while it is running on Windows 95/98/ME, think again. The operating system is not secure, and opening your system to the world is asking for trouble.
If you really need to go "live", my suggestion is to install Linux into another partition (or disk) and read up on how to tightened your security and run your Apache server from there. Linux, by the way, is free.
Precompiled executables, complete with a Setup program, of the Apache server are available from the Apache website.
Download and run it to get the server copied onto your machine.
During installation, a dialog box will appear asking you for your domain name and server name. Simply enter "localhost" for both. Enter whatever email address you wish for the email address field. The installer uses these values to create a default Apache configuration file for you. Choose also to install Apache with shortcuts to start it as a service for all users.
Under Windows XP, when you finish installing Apache, the installer will automatically start up the Apache service. To stop it and only start it manually when you need to use it for testing, go to Control Panel > Administrative Tools > Services, look for the Apache service and double-click it. From here you can stop the service and change the startup type to "Manual". The Apache service will then terminate and only start when you return to this control panel applet to manually start it. This is useful if, like me, you're only using the server to test your scripts, and don't want the server running all the time. Note that you will have to restart the service every time you make a configuration change.
If your version of Apache does not create a shortcut in the Programs menu that allow you to start the Apache server. Simply navigate to "c:\Program Files\Apache Group\Apache\" and double click on Apache.exe to start the server. To terminate the server, select "Close" from the window's system menu.
If you change your mind about the server name you chose when you installed Apache, you can always change it with your favourite text editor (such as Notepad from your Start menu | Programs | Accessories | Notepad) by searching for and replacing the following line in the "C:\Program Files\Apache Group\Apache\conf\httpd.conf" file.
If you want your server to handle Server Side Includes (SSI), use a text editor (like Notepad) to open "C:\Program Files\Apache Group\Apache\conf\httpd.conf". Search for "server-parsed HTML files" in the file, and add the following lines (or uncomment the example lines in the configuration file by removing the prefixed hash marks, "#").
If you want "index.shtml" to be your default start page for your directories, ie, if you want Apache to load "index.shtml" when you type "localhost" or "localhost/directory/", you will need to search for a line in your "httpd.conf" that begins with "DirectoryIndex" and modify it as follows:
Apache will now look for index.shtml first when it is given a directory without a file name, and only try index.html if index.shtml is missing.
Close the Apache window and restart it. You have to do this every time you make a configuration change so that Apache will reload the modified configuration file.
If you're using Internet Explorer, Firefox or Opera, you can test that you've properly installed and configured Apache by typing "localhost" or its IP address "127.0.0.1" into the location bar of the browser. You should see the default page installed by the Apache installer on your hard disk. It is located in "C:\Program Files\Apache Group\Apache\htdocs\". I have not been able to get earlier versions of IE and Netscape 4.73 to connect without the Dial-Up Networking dialog box popping up and insisting that I connect to my ISP (defeating the entire purpose of this exercise for me).
If you can't get your browser to connect to your local webserver, you can still test it by manually mimicking a browser. Go to the Start menu and select "Run". A dialog box will appear. Type "telnet localhost 80" (without the quotes) into the dialog box and click OK. The Windows telnet program will start up. Go to the Terminal | Preferences dialog box and make sure that the "Local echo" check box is selected (unless you are one of those who like to type blind). Type "get / http/1.0" (without the quotes) into the telnet window followed by hitting the Enter key twice. You will get a whole lot of text scrolling swiftly by. This is the default page installed by the Apache installer on your hard disk. If you can get this it means that you've successfully installed Apache.
The entire Apache manual set was installed on your machine in the "C:\Program Files\Apache Group\Apache\htdocs\manual\" subdirectory. Read it. This guide only covers installation. You (obviously) have to configure your server and learn where to put your documents and the like.
If you need to install PHP support into your server, check out my articles on How to Install and Configure PHP 5 to Run with Apache on Windows (for PHP 5) and How to Install and Configure PHP 4 to run with Apache 1.x on Windows (for PHP 4).
If you wish to support Perl CGI scripts on your server, check out the article on How to Add Perl CGI Support to Your Apache 1.x Web Server on Windows.
Remember, this installation guide is designed for you to install Apache for private offline use. If your site is going "live", I suggest that you not only learn how to configure from the manuals but also brush up on security issues as well.
This article can be found at https://www.thesitewizard.com/archive/apache.shtml
Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml. You can read more about how to subscribe to RSS site feeds from my RSS FAQ.
This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.
It will appear on your page as: