Install PHP 5 for IIS 6

Step by step guide on how to install iis6 and php5 on Windows XP or Windows Server 2003

Steps

  1. First you must install IIS 6.0. (IIS 5.1 on XP)
  2. On Windows XP, Go to your control panel > add remove programs. Click on "Add/Remove Windows Components". Place a check for "Internet Information Services". On Windows7 go to Start -> Control Panel -> Programs and Features -> Turn Windows Features On or Off. Make sure that all the options showed on the below image are checked.
  3. IIS 6.0 is now installed. Now you must get the correct files for php5. Head over to http://www.php.net/downloads.php and download the zip package under "Windows Binaries" Do not get the installer! In addition, while you are here you will need to get the "Collection of PECL modules" also under Windows Binaries.
  4. Once Downloaded extract the first file you downloaded and place the files in "C:\php". Extract the PECL modules to "C:\php\ext".
  5. Rename C:\php\php.ini-recommended to C:\php\php.ini and then COPY it to C:\Windows
  6. Open both the php.ini file you have now and uncomment cgi.force_redirect in php.ini and set it to 0
  7. Find SMTP = localhost and make sure it is un-commented. If your mail server is somewhere else you may specify it here. Also set this line just below the above: sendmail_from = someone@yourhost.com
  8. Change session.save_path as "session.save_path=C:\php\sessions" and make the directory C:\php\sessions
  9. Set the line "extension_dir" as "extension_dir = "C:\PHP\ext".
  10. Uncomment all of the following items.
    extension=php_mssql.dll
    extension=php_msql.dll
    extension=php_mysql.dll
    extension=php_mysqli.dll
    extension=php_java.dll
    extension=php_ldap.dll
    extension=php_iisfunc.dll
    extension=php_imap.dll
    extension=php_filepro.dll
    extension=php_gd2.dll
    extension=php_gettext.dll
    extension=php_dba.dll
    extension=php_dbase.dll
    extension=php_dbx.dll
    extension=php_mbstring.dll
    extension=php_pdf.dll
    extension=php_pgsql.dll
    extension=php_sockets.dll
    extension=php_xmlrpc.dll
    extension=php_xsl.dll
    extension=php_zip.dll

    The rest require more attention and is out of the scope of this tutorial.
    Some of the items might not be there. In that case, simply copy the line to your ini file.
  11. Now copy all of those DLL files in C:\php\ext to C:\windows\system32 or add "C:\PHP;" to your Windows path. To add php to your Windows path:
    • Right Click on My Computer and choose properties > Advanced Tab > Click "Environment Variables".
    • Now add "C:\PHP;" to the very beginning.
    • Now go to start > run > type: regedit and click OK.
    • Add HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = C:\php to the registry. If you change your windows path instead of copying the dll files then you will need to restart your computer before php will work. Updating php is easier when you add it to your Windows path. So bookmark this page and go restart. Now is the best time since we are done with file placement.
    • From the IIS Manager, click on the hostname of your server in the Connections panel on the left.
    • Double-click on the Handler Mappings icon.
    • From the Handler Mappings Actions panel, click on Add Module Mapping.
  12. Type the following information into the appropriate text boxes, and then click OK.
    • Request path: *.php
    • Module: FastCGImodule
    • Executable: C:\php\php-cgi.exe
    • Name: FastCGI
    • Click OK, and then click Yes.
    • In the left panel, click on your server’s hostname, and then double-click on the Default Document icon.
    • From the Actions panel on the right, click Add.
    • Enter index.php as the new default document name, and then click OK.
    • In the left panel, click on your server’s hostname.
    • In the Actions panel on the right, click Restart.
    • Create a new text document, and save it as c:\inetpub\wwwroot\phpinfo.php with the following content:<?php phpinfo(); ?>
    • You should now see the PHP information page at http://localhost/phpinfo.php.



Tips

  • If you need help, you can always use php.net for help. It is a great place for learning php too.
  • If php does not work, try uncommenting dll file extensions in the php.ini files. Remember there is one in your C:\Windows directory and one in your C:\php directory. It will use the one the windows path is.
  • If you add C:\PHP to your env variables, you could end up loading the php.ini from the C:\PHP folder (or your equiv)

Warnings

  • Once running, make a copy of C:\php and keep it. You may need this later. It is also a good idea to do an IIS configuration export.

Things You'll Need

  • A Windows XP SP2 or Windows Server 2003 Installation

Related Articles

Sources and Citations