#native_company# #native_desc#
#native_cta#

PHP with Apache on Windows? Piece of Cake!

By Rajeev Ranjan Rakesh
on November 29, 2007

You may have considered setting up PHP on your Microsoft Windows server that’s running Apache, but thought that it would be too tedious or clunky to be worth the effort. Wrong! We’ll get you up and running in no time flat with this speedy little tutorial!

First Step: Install and Configure PHP

  1. Download PHP from http://www.php.net/downloads.php
  2. Create a directory for php on your machine, i.e. c:php
  3. Extract the downloaded binary to a temporary location and then copy all the files from the unzipped directory to your c:php directory.

Note: the above steps for PHP version 4.X, there might be slight change in other versions.

Second Step: Configure Your Apache Server

  1. The first thing you will need to do is to load php as a module so it’s able to parse php. Script changes should be made in the httpd.conf file, typically found in the directory “C:Program FilesApache GroupApacheconf”. Search for the “LoadModule” statement and add the following directly after it:

    LoadModule php4_module “c:/php/php4apache.dll”

    Note: If you are using apache version 2.X then use “c:/php/php4apache2.dll” instead of “c:/php/php4apache.dll”.

  2. Now search for “AddType” in the conf file and at the end of the AddType statement add the following:

    AddType application /x-httpd-php .php

  3. If you wish to use index.php as the default page for a directory, search for “DirectoryIndex” and change the line that says

    “DirectoryIndex index.html”

    to

    “DirectoryIndex index.php index.html”

  4. Create a test php file to test the installation. Use the following php code in the test file:
    <?phpinfo() ?>

    Save this file as “phpinfo.php” and store it in your apache htdocs directory.

  5. Restart the apache server and type
    http://localhost/phpinfo.php

    in your browser to check to see if it is configured properly.

Conclusion

Installing PHP to work with the Apache web server on Windows is not the huge challenge that it once was–so now you don’t have any excuses–get out there and try it on your own server!