How to Install PHP 5.x on Windows


PHP Install Tutorial

This php tutorial is intended for developers - both beginners and Experts to setup a testing WAMP server on personal computers or laptops.

PHP Tutorial Covers:

How to Install PHP 5 on Windows 7.


  1. An Apache web-server installed and running (Click here for Apache installation instructions)
  2. PHP 5 software (Download here)

PHP Windows Install Steps

  1. Download PHP Zip File.
  2. Create a Folder "c:/php".
  3. Extract the PHP Zip file to "c:/php".
  4. Set Windows environment variable for PHP.

    Setting the Environment Variable "makes" the "c:/php" path "known" to Windows 7 operating system.

    1. To set the environment variable for php do the following.

    2. Go to start on your desktop
    3. Control panel
    4. System
    5. Advanced
    6. Environment Variables
    7. Select "path." and type in "c:/php;" at the end of the other stuff in the text-box
  5. Next We Focus On php.ini.
    1. Using Default php.ini Configurations

      Defaults with a few exceptions will get us up and running.
      I DO suggest, however, that you mske time to go over to when you are ready to delve into more complex configurations.

      Now Some Noteworthy Points

    2. php.ini holds the core PHP configuration settings.
    3. php.ini is text-based and the syntax is simple and easy to learn.
    4. php.ini,by default, can be found in the php install directory -
    5. Open your php.ini file in a text editor. I recommend Notepad++ for Windows.
    6. Type ctrl-f
    7. Search php.ini for "doc_root"

    8. Set doc_root to the Apache Web-Server install folder:

      doc_root = "C:Apache Software FoundationApache2.2"

    9. Set "extension_dir:"

      The extension directory is where you find and add php extensions. Windows php extensions are binary ".dll" ( stands for dynamic link library) files with php_ added to the front of the filenames.

      extension_dir = "C:phpext"

  6. Changes To Apache httpd.conf

    http.conf holds all the apache server configurations


    1. Select start / all programs / Apache http server / Configure Apache Server / edit the Apache httpd.conf configuration file.
    2. Add the following lines of code to the top of the page.

      For Apache 2.2

      1. LoadModule php5_module "c:/php/php5apache2.dll"
      2. AddType application/x-httpd-php .php
      3. PHPIniDir "c:/php"

      For Apache 2.4

      1. AddType application/x-httpd-php .php
      2. AddHandler application/x-httpd-php5 .html .htm
      3. PHPIniDir C:/php
      4. LoadModule php5_module C:/php/php5apache2_4.dll
  7. Reboot Windows And your installation Is complete!

When Windows loads back up you will probably see status messages about Apache and PHP starting. If all has gone well with your installation, the Apache should server will start.

If your web server won't run, then you probably made a mistake in either the httpd.conf file or the php.ini file.

This would be great time to go back and get those backups from earlier in th tutorial

Make sure that you did not change anything accidentally such as typing an accidental character or space by bumping the keyboard.

If all else fails, Call Obewan and drop in the backup configurations files to their respective folders which should restore balance to the force!

Conversely if Everything is Up and Up (Router/Networking GeekSpeak for those of us who took Cisco Netecad)

Then it's time to write your first script and test out your new development box!.

  1. Open a text editor like Notepad++ or notepad for windows
  2. Create a file called "test.php," and save it in your Apache "htdocs" (web-server root folder).
  3. Now write the following PHP script into your newly created file

< ?php echo '< h1>My PHP must be working!< h1>';? >

Test It

  1. Open your web-browser and type in http://localhost/test.php.

If everything is working you will get this output:

My PHP must be working!

Now you are ready to start learning how to write PHP.

Author: D.Shaun Morgan