Install PHP5 for Windows (Apache2)

February 14th, 2008 by keith Leave a reply »
  1. Download & Unpack

    Download and install PHP from http://www.php.net/downloads.php, you should grab the newest 5.x.x Windows Binary zip package that will work on apache.

    My file was named: php-5.2.4-Win32.zip

  2. Unzip php. In my case, I unzipped to:
    C:\php\
  3. Rename C:\php\php.ini-dist it to php.ini
  4. Edit your php.ini

    Open php.ini in a text editor and scroll down about halfway through the file and look for doc_root then change it to point to whatever your Apache DocumentRoot is set to. In my case: doc_root = “e:\public_html”

    Scroll down about 7 more lines and change the extension_dir from extension_dir = “./” to the location of the ext directory after you unzipped PHP. in my case: extension_dir = “C:\php\ext”

    and add the files you want apache to look for when a directory is loaded (if it doesn’t find any of these files, it displays folder contents). Mine looks like:

    <IfModule dir_module>
         DirectoryIndex index.php index.html default.html
    </IfModule>
  5. Testing

    Restart Apache if it is already running (if it doesn’t start or you get errors, use your Apache “Test Configuration” shortcut in the Start Menu to see why).

    To test your PHP simply create a test.php file in your Apache “DocumentRoot” folder (C:\public_html\ in my case). In your test.php file, type these 3 lines and then load the file in your browser like http://localhost/test.php (you should get a whole long list of php variables, settings, etc):

    <?php
    phpinfo();
    ?>
  6. Documentation Suggestion

    One weird thing I have noticed about PHP is that it does not come with documentation of any kind. If you are a php developer/programmer, I suggest you download the documentation. Downloads can be found on http://www.php.net/download-docs.php and I personally recommend the “English – Windows HTML Help” (chm) version as the search is so handy, although they all contain the same information.

Advertisement

Leave a Reply