Web Development

  Homes arrow Web Development arrow Turning Your Windows PC Into An Apache Web Se...
 Webmaster Tools
Base64 Encoding 
Browser Settings 
CSS Coder 
CSS Navigation Menu 
Datetime Converter 
DHTML Tooltip 
Dig Utility 
DNS Utility 
Dropdown Menu 
Fetch Content 
Fetch Header 
Floating Layer 
htaccess Generator 
HTML Encoder 
HTML Entities 
IP Convert 
Meta Tags 
Password Encryption
Password Strength
Pattern Extractor 
Ping Utility 
Pop-Up Window 
Regex Extractor 
Regex Match 
Scrollbar Color 
Source Viewer 
Syntax Highlighting 
URL Encoding 
Web Safe Colors 
Forums Sitemap 
Weekly Newsletter
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Contact Us 
Site Map 
Privacy Policy 
  >>> SIGN UP!  
  Lost Password? 

Turning Your Windows PC Into An Apache Web Server
By: Developer Shed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3

    Table of Contents:

    Rate this Article: Poor Best 
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article




    Turning Your Windows PC Into An Apache Web Server

    By: Ben Rowe


    A lot of people use the Apache/PHP/MySQL combo on their machine for development of web sites and other small scripts. Most PHP developers reading this article will be on a Windows based machine and will use it to developer their sites. When they are done they will upload them to a Unix/Linux production server.

    So, you think you've got your web server set up, right? Hands up all who are using the Windows installer version of PHP and not the binary version. For all of you who just put your hands up, this article was written for you.

    In this article I am going to step you through installing Apache, PHP and MySQL on Windows. For this article, you will need to download 3 files and have full unrestricted access to your machine (this applies to Windows NT/2000 and XP users).

    Please note that for this article I'm going to be showing you how to set up your web server on windows 2000. The instructions are the same for XP, but for 98/ME users you will need to change a few things (I will of course let you know what needs changing).

    [Note] Because most web hosts are still using Apache 1.3 and not version 2.0 r above, I'm going to show you how to install Apache version 1.3 [End Note]

    Installing Apache

    Firstly we will need to actually get the web server up and running. If you have an older installation of Apache on your web server then I suggest that you remove it.

    You will need to backup your httpd.conf file for Apache, your php.ini for PHP, your MySQL database as well as any document in your htdocs or public_html folder.

    We need to download our Apache installer file. We're going to install the binary no source version. You can download the file here. Save this to a location on your PC. Once it has finished downloading, run the file (It is a .MSI file -– A Microsoft Installer File). It should bring up the installer window, like this:

    Click next to bring up the licence agreement. Once you have accepted the terms and conditions, select the 'I accept the terms in the licence agreement' button and click next. Up will pop the read me screen -- read this if you wish. Click next to continue.

    Next up we have the server information dialog:

    Copy the details that I have provided in the screen shot above. Because we are setting up a development server, enter localhost in the network domain and server name fields. Also, enter your current email address in the adminstrator's email address field. This is used for errors and as the from address when you use PHP's mail function. Lastly, it's best if you let apache run as a service -- this way it will always be running in the background.

    Once you have filled out the form, click next to continue. The installer will then bring up an install type dialog. Select complete from the list and continue. Finally before it installs, Apache will let you choose a location to install it to. The default location is C:\ Program Files\ Apache Group\

    I would suggest leaving the default install path, but if your feeling game then you can install it in another location... just remember this can cause problems later.

    Click next then click Install. Apache should begin installing on your system -- a few screens should fly by and within minutes you should have Apache ready to roll!

    To test that the server has been installed correctly, open up a new browser window and type 'http://localhost/' in the address bar. You should now see the confirmation document from Apache.

    [Note] If you're also running IIS then Apache would've detected this and set itself up on port 8080 instead of the default port 80, so visit http://www.localhost:8080 instead [End Note]

    Installing MySQL

    Installing MySQL is a breeze. Firstly, we need to download the latest version of MySQL, which you can get here. Once you have downloaded the file, open and unzip it to a temporary directory on your PC. Open the directory you have unzipped it into and run the setup executable. This should launch the setup program.

    Step though the various windows using the default install options. Once the install is complete, you can delete the temporary directory. To get MySQL up and running, open c:\mysql\bin\ and run winmysqladmin.exe. It may ask you for an administrator username and password. If so, select a username and password of your choice and enter them here. This window should now minimise and you should see a traffic light icon in your system tray. If MySQL is running, it should be green.

    That's all there is to setting up MySQL on a Windows PC!. The installation of PHP is a bit more complex then Apache and MySQL, however. Because we are going to install the binary version and not the install version, it's going to need a bit of tweaking, but it's well worth it in the long run. The main differences between the binary and install version is that the install version doesn't have full support extensions, amongst other things.

    Installing PHP
    Again, download the latest version of PHP here. Once you’ve downloaded it, unzip it into a temporary directory, preserving the directory structure. Open the temporary directory -- there should be just one folder. Copy that folder to your root directory, c:\

    Rename the folder to "php". You should now have a folder located at c:\php that contains all of the setup files and executable files for PHP.

    You should see a file called php4ts.dll in your c:\php folder. If you don't then click on the tools -> folder options menu and then click on the view tab and select 'Show hidden files and folders' from the list. Click Ok. You should now be able to see the php4ts.dll file.

    Copy this file and move into your window system folder (c:\winnt\system32). Go back to your PHP folder and you should see a file called php.ini-dist. Copy this file into your windows directory (c:\winnt) and rename it to php.ini.

    Now that we have Apache, MySQL and PHP installed we need to configure them, which is what we will do next.

    We will need to edit two files to get Apache, MySQL and PHP to run together. Firstly, located in c:\ program files\ apache group\ apache\ conf\ there should be a file called httpd.conf. Open this file with notepad.

    We will need to change the following things:

    Search for (CTRL+F)

    DocumentRoot "C:/Program Files/Apache Group/Apache/htdocs"

    ... and change the location to "c:/public_html/"

    The reason why we are using the c:/public_html to contain our files is because it is easier to find and much easier to remember then the default htdocs directory.

    Search for

    DirectoryIndex index.html

    This is the list of default files that apache will look for when you reference a directory through your web browser instead of a specific file (e.g. http://localhost/folder/ instead of http://localhost/folder/myfile.php)

    Add index.php or any other default files you wish. They should be separated by spaces, just like this:

    DirectoryIndex index.html index.php default.html

    Lastly, if you want to use .htaccess files you will need to enable them. Search for AllowOverride None and change the None to All. You will now be able to use .htaccess files.


    LoadModule php4_module c:/php/sapi/php4apache.dll
    AddModule mod_php4.c
    AddType application/x-httpd-php .php

    ... to the bottom of the httpd.conf file. This tells Apache that whenever a user requests a file with a .PHP extension that it should pass this file to the PHP module for parsing before sending it to the user.

    Save the file and close notepad. To test your work so far, create a folder called public_html in your root directory (c:\) and place an index.php file in this directory containing the following PHP code:

    <?php echo "This is working!"; ?>

    You will also need to restart your web server. There should be a shortcut in your start menu to do so under the Apache folder that was created when you installed Apache. If everything is OK then you should be able to bring up the index.php file with by visiting http://localhost/index.php in your web browser.

    Open c:\winnt\php.ini with notepad. If you want to use the extension libraries that come with PHP then you will need to setup the extensions directory. When you installed PHP in c:\php, a sub-directory called extensions was also installed in c:\php. Search php.ini for the line

    extension_dir = ./

    ... and change it to

    extension_dir = /php/extensions/

    This tells PHP where your extensions folder that contains the extensions resides. To enable individual extensions you need to remove the semi-colon in front of each library you require and restart your web server. These extensions can be found under the dynamic extensions section of your php.ini file. For example, if I wanted to use the DOM XML extension then I would change


    ... to


    For all of you ASP developers-come-PHP-developers out there, you can setup short tags for PHP (<? instead of <?php) and even ASP type tags <% %>.

    To enable short tags, search for

    short_open_tag = Off

    ... and change it to

    short_open_tag = On

    To enable ASP type tags, search for

    asp_tags = Off

    ... and change it to

    asp_tags = On

    When you're done fiddling around with your settings, save the file and restart your web server using the restart link in the Apache folder on your start menu.

    You now have a fully working Apache, MySQL and PHP web server running under Windows... congratulations!


    By now you should know how to set up an Apache server on Windows with PHP and MySQL working as well. A lot of people don't know how to get the most of out their web server and a lot of windows based servers still run the installation version, which in my experience can caused a lot of hard to find problems.

    If you are having trouble installing Apache, PHP or MySQL then click here to visit our forums for help. If you're just new to PHP then make sure you visit our PHP category and read through the dozens of articles in the list.

    Top quality daily ASP, PHP and .NET
    articles, tutorials, news, reviews, interviews AND FREE EBOOKS! devArticles is
    the ultimate online resource for the serious web developer. Visit
    http://www.devarticles.com today!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Web Development Articles
    More By Developer Shed



    - On Page SEO for New Domains
    - Improve Your Site`s Speed
    - Safari Books Online Review
    - Creating an Estore From the Ground Up
    - Most Common SEO Mistakes Developers Make
    - Making the Most of Your Titles and Meta Desc...
    - Five Ways Using Flash Can Damage Your Site
    - A Web Designer`s Guide to Colors
    - Use Webstarts to Create a Free Site
    - More Than Just Looks. How Your Web Design C...
    - How to Design Content Pages
    - Mint Review
    - Make Your WordPress Website Look Professional
    - How to Create a Mobile Web Site
    - Meta Tags: Still Useful?

    Developer Shed Affiliates


    © 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap