If you want to write your own PHP scripts, you'll need to install the PHP engine first. It's relatively easy, and this article will show you how to do so.

Steps

  1. If you haven't done so already, download the PHP Windows Binaries - You can download the software from the PHP.net website, ( http://www.php.net/downloads.php ) Be sure to download PHP 5.2.9 installer Windows installer and PHP 5.2.9 zip package. (Note: the version numbers might be different). Save the files on your Windows Desktop.
  2. Once you've done that, you should see a window that looks like this:
    Advertisement
  3. We're going to install PHP in our server directory instead of the default PHP directory, so in the "Destination Folder" group, click "Browse".
  4. Change the destination directory to "C:\Server\PHP". There is no need for a trailing backslash.
  5. This will be used as the "From:" email address when using PHP's mail function.
  6. Then click "Next>".
  7. Since you have installed Apache, pick "Apache" from the list. Then click "Next>".
  8. PHP is ready to install, so click "Next>" to begin the installation.
  9. 16
    If a message window pops up asking, "Do you want to keep your php.ini file", click "NO".
    • This is normal. Click "OK". When the PHP installer window pops up, click "OK" again.
  10. 18
    Now PHP is installed, but we need to change some of Apache's settings to get everything working the way it should.
  11. \Server\Apache2\conf".
  12. This will normally open the file in Notepad, unless you use a different program.
    • ScriptAlias /php "c:/server/php/"
    • AddType application/x-httpd-php .php
    • Action application/x-httpd-php "/php/php-cgi.exe"
  13. 22
    Highlight and copy the text from this page, and then paste it into the httpd.conf page to ensure there are no typos. Hit "Enter" after the last line to ensure there is one blank line at the end of the file.
  14. 23
    Move the file "C: \Windows\php.ini" to the directory "C:\Server\php" so it's easier to edit when you need to.
  15. \Windows".
  16. \Server\php".
  17. This moves the "php.ini" file from the Windows directory to the PHP directory.
  18. 29
    Double click the file php-5.2.9-win32.zip that is saved on your desktop. (Note: the version number might be different).
  19. \Server\php"
  20. \Server\php\php.ini".
  21. extension_dir = "./" (or something similar, as long as its the line with "extension_dir".
  22. extension_dir = "C:\Server\php\ext"
  23. ;extension=php_mysql.dll Delete the ; so that the line now reads: extension=php_mysql.dll
  24. \Server\MySQL\bin".
  25. \Windows\System32" and Paste the file into that directory.
  26. This should restart the Apache server. Now we need to create a test PHP to see if everything is working.
  27. Open Notepad (usually found in "Start">"All Programs">"Accessories">"Notepad"), and copy and paste the following lines into a new document: <?php phpinfo(); ?>
  28. Save this file in the directory "C:\Server\Apache2\htdocs" as "phpinfo.php". Notepad has a bad habit of adding .txt to the end of all documents you save, so make sure from the "Save" dialog that comes up in Notepad, change "Save as type" from "Text Documents (*.txt)" to "All Files". Now click the "Save" button to save your new PHP document.
  29. 43
    Open your favorite browser. In the address bar, type "http://localhost/phpinfo.php". If everything is set up correctly, you should see a page that looks like this:
    Advertisement

Expert Q&A

Ask a Question

      Advertisement

      Video

      Tips

      • Add the following lines:
        • Order allow,deny
        • Options None
        • Allow Override None
      • If you want to save your time, use XAMPP software bundle. It is most simple way to install Apache, PHP, MySQL on Windows.
        • Be sure to make these last changes to the Apache configuration file to prevent a 403 FORBIDDEN message when testing to see if PHP has been successfully installed:
          • <Directory "c:/php/">
          • </Directory>
          • Allow from all
      Advertisement

      About this article

      Thanks to all authors for creating a page that has been read 234,200 times.

      Is this article up to date?

      Advertisement