http://www.peterguy.com/php/install_IIS6.txt Last changed 10:40 PM 2/7/2005 questions/props/corrections/etc... > petera spammer-at-peterguy.com (delete a spammer to email) flames > /dev/null ;-) !!!!!!!!!!!! NOTICE !!!!!!!!!!! This guide is no longer being maintained. You will find the most up-to-date information in a much better-looking html-formatted guide at http://www.peterguy.com/php/install_IIS6.html Please go there now. :-) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 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. YMMV. The lines beginning with dashes are the steps, the stuff in between is more detail should you need it. I'm hoping to convert this to an html-based guide that's prettier, but my time is limited. This guide does not cover initial setup of IIS, or configuration of a Windows 2003 server in general. This guide is divided into 3 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) So, let's get into it... ************************* 1. Install PHP ************************* 1.1 Unzip latest version of PHP to C:\PHP (I used 5.0.2) Download the latest zipped distribution of PHP from 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 browscap.ini (I got it from http://www.garykeith.com/browsers/downloads.asp - php_browscap.ini) 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. Click on the "Add" button, then enter in the rather large text box, "IUSR_". Click on "Check Names" to have it find the user for you. If it can't find the username, a "Name Not Found" dialog box will display. In that case, "Cancel" the "Name Not Found" dialog, then click the "Advanced" button. This will open another dialog, where you'll click on the "Find Now" button, then scroll through the list of "Search results" to find the Internet Guest account (Probably displayed as IUSR_). 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" 2.7 Uncomment the desired extensions in php.ini (search for "extension=") 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 - right-click on My Computer, choose Properties - flip to the Advanced tab - click the Environment Variables button - Double-click the Path variable in the list of System variables. - Either add "C:\PHP;" to the beginning, or ";C:\PHP" to the end. - Re-boot the server for it to take effect. 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". As a side note, phpBB2 does not work with MySQL 4.1.x or PHP 5.x. If you want to use php extensions, you'll have to change the value of extension_dir in php.ini to be \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. 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. --------------------------------------------------------- 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 Right-click on "Web Sites", goto Properties->Home Directory->Configuration...->Application Extensions, add a new extension: .php using C:\PHP\php5isapi.dll; allow 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". You made it, configuration is all done! 3.4a Restart IIS Right-click the local computer in the left pane of IIS Manager, click on All Tasks->Restart IIS...->OK *** OR *** 3.4b Reboot server Only if you modified the server's PATH environment variable for the extensions and haven't rebooted yet. ************************* 4. Test your setup ************************* 4.1 Create a new file named test.php in one of the websites containing the single line below: 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. 4.2 Point browser there to test. *** NOTE *** 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. !!!!!!!!!!!! NOTICE !!!!!!!!!!! This guide is no longer being maintained. You will find the most up-to-date information in a much better-looking html-formatted guide at http://www.peterguy.com/php/install_IIS6.html Please go there now. :-) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!