How to install PHP 5.x on Windows Server 2003 with IIS 6
"A detailed and hopefully helpful step-by-step guide, based on my experience."
http://www.peterguy.com/php/install_IIS6.php
Last changed 11:33 AM 12/27/2004
questions/props/corrections/etc... > petera spammer@peterguy.com (delete 'a spammer' to email)
flames > /dev/null ;-)
0. Notes before we start
0.1 This guide does not cover initial setup of IIS, or configuration of a Windows 2003 server in general.
No Notes
0.2 This guide is divided into 5 main steps:
1. install PHP (the easiest step, like having a baby is to raising a child)
2. Configure PHP (lots of php.ini editing)
3. Configure IIS (lots of pointing and clicking in IIS Manager)
4. Test it!(checking to make sure PHP is working on your server)
5. Troubleshooting (let's hope you don't need this section :-P)
0.3 YMMV
Different people will be helped in different ways with this guild... this just worked for me.
1. Install PHP
1.1 Unzip latest version of PHP to C:\PHP
Download the latest zipped distribution of PHP from http://php.net, not the Windows installer.
You can pick any drive, and any folder, but the recommendation is to put all the PHP stuff in a folder just off of the root drive, like C:\PHP, and this guide will follow that recommendation.
1.2 Rename/copy php.ini-recommended to php.ini
In your PHP directory, you'll find a couple of php.ini-* files. They are pre-configured settings for a PHP install that you can use as an initial setup. php.ini-recommended is the most secure, hence, the recommended one; just rename it to php.ini, overwriting any existing php.ini.
2. Configure PHP, mainly editing php.ini
2.1 Uncomment "cgi.force_redirect" in php.ini and set equal to 0
*** This is a very important step, don't neglect it. ***
2.2 Download a browscap.ini
I got it from http://www.garykeith.com/browsers/downloads.asp (Use php_browscap.ini) Rename and save it to C:\PHP\extras\browscap.ini
2.3 Uncomment and edit the browscap variable in php.ini to point to C:\PHP\extras\browscap.ini
You don't have to install a browscap file, it's just for those who want to use the browser identification features of PHP. It's pretty straightforward: download php_browscap.ini from the above website to the extras directory under your PHP install directory, and change the variable in php.ini to point to the browscap file.
2.4 Grant IUSR Read and Execute, and Read permissions on php.ini
This is so that the unauthenticated Internet User (under which PHP will run in a website) will have read access to the configuration file. Right-click on your newly-created php.ini file, then click on "Properties" in the list that pops up. This will open a dialog box with several tabs. One of the tabs is named "Security". Click on it. This tab shows a list of users who have permission to access the file.
If you can't find the Internet Guest account, then make sure IIS is installed and enabled, which is a whole 'nother subject. :-)
Once you find the Internet Guest Account, "OK" your way out of all dialogs. The default permissions are Read and Execute, and Read. You can probably uncheck the Read and Execute checkbox, although I left the default permissions.
2.5 Create a session state directory, grant IUSR full control to it, and point "session.save_path" in php.ini to it.
If you need to use PHP sessions, be sure to uncomment and change session.save_path to point to a valid directory somewhere to which IUSR has full control permissions. I created a "C:\PHP\Sessions" directory. I haven't explicitly tested this yet, I'm following the directions of others.
2.6 set "extension_dir" in php.ini to "C:\PHP\ext"
No Notes
2.7 Uncomment the desired extensions in php.ini (search for "extension=")
For information on extensions, visit http://ca3.php.net/manual/en/install.windows.extensions.php
2.8 Do one of two things:
   a. Copy all non-php dll files from C:\PHP to C:\Windows\System32 (or somewhere else in the server's PATH)
      - OR -
   b. Add "C:\PHP" to the server's PATH environment variable
2.9 If you're going to use MySQL 4.1.5 or later, add the line, "extension=php_mysqli.dll" to the ini file, right after "extension=php_mysql.dll".
If you want to use php extensions, you'll have to change the value of extension_dir in php.ini to be <PHP install dir>\ext (for PHP 5) and uncomment the applicable "extension=..." lines, then place the helper library files somewhere in the server's PATH, either by copying them, or modifying the PATH. I couldn't get some of the extensions to work, but most of them did.
The MySQL connector has to be mysqli for MySQL 4.1.5 or later.
** As a side note, phpBB2 does not work with MySQL 4.1.x or PHP 5.x.
2.10 Add to the registry HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = C:\PHP
This is so that PHP can find its configuration file. To make it easy on you, modify the following text between the dashes so that "C:\\PHP" is the directory in which you've unzipped PHP, then copy the text (sans dashes) and paste into a new text file (anywhere, the Desktop is a good place to create it). Rename the file to "inifilepath.reg", then double-click on it, click "Yes" to the confirmation dialog, and the value will be in place. You can then delete inifilepath.reg.
Make sure all backslashes are escaped (ie. \\ instead of just \)
---------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]
"IniFilePath"="C:\\PHP"
---------------------------------------------------------
3. Configure IIS
- For the rest of the steps, open IIS Manager (Start->Control Panel->Administrative Tools->Internet Information Services (IIS) Manager).
3.1 Add and allow the PHP ISAPI Extension to IIS Web Service Extensions: C:\PHP\php5isapi.dll
When you open IIS Manager, it should connect to the local computer automatically. Expand the local computer in the left pane, then click on "Web Service Extensions" in the left pane.
In the right pane, now, click the blue underlined text, "Add a new Web service extension...". Enter "PHP ISAPI Extension" as the "Extension name", then click the "Add..." button and browse to the php5isapi.dll file in your PHP install directory.
There are two ways to setup PHP for the web: ISAPI and CGI. ISAPI is typically more efficient and secure. If you want to add the CGI extension, in addition to or instead of the ISAPI, repeat the above, but enter "PHP CGI Extension" as the "Extension name", and browse to php-cgi.exe in your PHP install directory for the "Required files".
Once you've named it appropriately and chosen the desired file, check the "Set extension status to Allowed" checkbox and click "OK".

** The following two steps are suggested to apply to the "Web Sites" root folder in IIS Manager, but they can be applied to individual sites, instead. When applying changes to "Web Sites", note that a dialog might come up asking if you want to apply changes to a list of specific websites, too. Note that the listed sites will be ones that have overridden any default values, so be careful about applying changes to them. Especially be careful of applying changes to the Microsoft SharePoint Administration site (thus speaks painful experience).
3.2 Add new extension (.php)
Right-click on "Web Sites", goto Properties->Home Directory->Configuration...->Application Extensions, add a new extension:
Extension: .php
Executable: C:\PHP\php5isapi.dll Select radial button "Limit to": GET,POST,HEAD.
This will apply to every website.
This sets up IIS to actually respond to requests for php files. "Web Sites" is a "folder" in the left pane of IIS Manager. php5isapi.dll will be in your PHP install directory. Replace php5isapi.dll with php-cgi.exe if you chose the CGI extension.
3.3 Turn on scripting permissions for your websites
Right-click on "Web Sites", goto Properties->Home Directory.
Change the "Execute permissions" dropdown to "Scripts only".
3.4 Restart IIS or Reboot Server
Right-click the local computer in the left pane of IIS Manager, click on All Tasks->Restart IIS...->OK
- OR -
If you modified the server's PATH environment variable for the extensions and haven't rebooted yet, reboot now.
4. Test your setup
4.1 Create a new file named test.php in one of the websites
Expand the "Web Sites" folder in the left pane of IIS Manager to see a list of existing websites. Right-click->Properties->Home Directory->Local Path will show you where the website root directory is.
Contents of test.php:
<?php phpinfo(); ?>
4.2 Point browser there to test.
*** If you uncommented extensions, be sure to test this from the server's console, not another computer, or even Terminal Services. Some of the extensions don't work, and an error dialog will pop up on the server console telling which one didn't work. You have to be able to click "OK" to the dialog for the page to finish loading. Take note of the extension that didn't work, click "OK", and then comment out the extension in php.ini until you can figure out how to get it to work. ***
5. Trouble Shooting
5.1 It wont work!
Try this: right click on WebSites > Properties > ISAPI Filters > Add >
filtername = PHP
executable = php5isapi.dll
5.2 I get an error about browscap.ini
Try and make sure that IUSR_<SERVERNAME> has read / read and execute permissions.
© MMV - Designed by apparition.Designs