Tutorials > Setting Up a Development Environment > Installing PHP

3. Installing PHP

  • This article assumes you have completed the previous tutorials up to: Apache Basic Setup
  • Go to http://windows.php.net/download/ and download the VC6 x86 Thread Safe Installer. I've found that version 5.2 tends to be the most universally compatible.
  • Run the install.
  • Install to C:\PHP\.
  • Under Web Server setup choose Apache 2.2.x Module.
  • Change the Apache configuration directory to C:\Apache\conf\.
  • On this screen you can select which PHP extensions to install. You can change this later.
  • I usually install these: bzip2, Curl, GD2, Mcrypt, MySQL and MySQLi.
  • Click next and then install. Once finished close the installer.
  • You need to restart Apache before PHP works, but first you need to verify it was setup correctly.
  • Open C:\Apache\conf\httd.conf and scroll to the bottom. You will see 4 lines have been added by the PHP installer. Make sure it matches the following:

    PHPIniDir "C:/PHP/"
    LoadModule php5_module "C:/PHP/php5apache2_2.dll'"
  • Restart Apache.
  • Goto C:\wwwroot. Create and open test.php.
  • Add this code to the file and save it.

    <?php
    echo "PHP works.";
    ?>
  • Open up a browser and go to http://localhost/test.php, you should see the message 'PHP works'.
  • Now that PHP is working, lets change the default file from index.html to index.php.
  • Open C:\Apache\conf\httpd.conf.
  • Change the directory index from 'DirectoryIndex index.html' to 'DirectoryIndex index.php index.html' and save.

    DirectoryIndex index.php index.html
  • Restart Apache.
  • Rename test.php to index.php.
  • Go back to your browser and remove test.php from the address, so it just says localhost, and hit enter.
  • It should still say 'PHP works.' since that is what is in index.php

Return to TutorialsNext Tutorial: Installing MySQL