WeblinkIndia logo
+91-9811948545 Get a Call Back

Configuring PHP 5 With Apache 2 On Windows

Web Development | Admin | Updated: 2011-01-31

Configuring PHP 5 With Apache 2 On Windows

PHP or Pre Hypertext Processor is the one of the most used languages that has revolutionized the way programmers are developing websites. Running PHP on the Apache server helps you to run tests on a live environment and take any actions if required. This write-up guides you step by step on configuring PHP 5 with Apache 2 on Windows system, starting from installation to offering other alternatives as well.

  • To use PHP on Windows with Apache, you should install the 2.2.x version on your system. To check if it has been installed- type http://localhost on the address bar of the browser and if the Apache Page appears, then it is confirmed.
  • Extract the PHP 5 folder in the C drive and rename the file php.ini-recommended as php.in.
  • Open the 'conf ' folder after going to the Apache directory. Modify 'httpd.conf ' and after that find LoadModule to replace it with the following :
    • For Apache 2.2.x: LoadModule php5_module "c:/php/php5apache2_2.dll"
    • For Apache 2.0.x: LoadModule php5_module "c:/php/php5apache2.dll"
  • In Apache 2.2.x, search the section for "AddType" lines and add this line right before the section closing.
    • AddType application/x-httpd-php .php
  • Add the following line anywhere in the file to let the server run the PHP executable every time a PHP script is encountered. Either add it in the comment block for Action or in case of Apache 2.2.x, you can add it after the AddType statement.
    • Action application/x-httpd-php "/php/php-cgi.exe"
  • Modify DirectoryIndex index.html to DirectoryIndex index.php index.html.
  • Start the Apache web server again.
  • Create a PHP file having the following line and save the file in the root directory of the server with the name test.php.
  • Now run Apache and open http://localhost/test.php (If you were able to configure successfully, then PHP information page is displayed or else the line is seen in the browser as text. In that case you can check the problem with the CommandPrompt window by running php-cgi.exe and the following line:
    • c:phpphp-cgi test.php

Another option is to use PHP Triad or WampServer, where configuring PHP and Apache is not required. If you can download the software then you get built-in support for MySQL, Apache and, PHP. Then you just need to install them and run.

1 thoughts on "Configuring PHP 5 With Apache 2 On Windows"

  • Mary
    07 December, 2011 at 4:06 pm

    Awesome site with good article information. Keep posting.


Add a Comment

Your email address will not be published. Required fields are marked *