Google

Friday, October 26, 2007

php on IIS 6 intallation

PHP is a really cool server side scripting interface with loads of options and modules and is relatively easier than ASP (the only other server side scripting language I've used). IIS 6 is also a cool web server with loads of new options. So here is how you configure php on IIS:(I'm assuming IIS is already installed on your box)
1. Download php from this location2. Unzip the package to some location(c:\php or whatever)3. Copy the php.ini-recommended file to your %systemroot% directory(usually C:\Windows) or to the %PHPRC% location, if %PHPRC% variable is set.4. Rename the file as php.ini5. Edit the file to make your config. I usually do the following(only minimal stuff):a. Open short tags ("" should work for me, I'm too lazy)b. Edit my extension_dir to the right location("c:\php\ext\" or whatever)** DO NOT FORGET TO PUT THE TRAILING BACKSLASH.**c. Enable my extensions...like php_ldap etc...d. other stuff...error handling, session mgmt etc etc....please read the docs. :-)6. Open your IIS snap-in (inetmgr in "Run")7. Create your website/virtual directory.8. Enable php on the entire website or your virtual directory:a. Go to the directory tab, click configuration, click Add.b. Put in ".php" (without the quotes) in the extension box.c. Point the Executable file to "php5isapi.dll" (in your php directory)d. Give your verbs(usually GET,HEAD,POST,TRACE would do)e. Ensure "Check that file exists" is checked. (saves time and resources)9. Only for IIS 6:a. Click on "Web Service Extensions".b. Click "Add new web service extension"c. Give some name and add the php5isapi.dll file and select allow.10. Add the php directory to your path(sysdm.cpl in "Run",Environment Variables under the Advanced tab, under "System Variables", edit the Path variable and append the path to your php directory to it(like C:\php where C:\php is the location of your php source).11. Restart IIS and enjoy.
Update(thanks to 'anonymous' :-): One important point I forgot to mention - You need to give the user IIS is running as (usually IUSR_MACHINENAME) permissions on your php directory and files, other wise you will end up with 403 or 404 errors.
I've seen on a lot of posts where people mention that they need to copy some files to system32 directory, and I do not think that its required. Here is a filemon snapshot of the location my IIS is finding the extensions:

Each time you make any changes to the php.ini file, you need to restart your webserver.
UPDATE: If you get a prompt for username and password in Firefox even though you enabled just anonymous access, you need to enable the following:a. In your Firefox window,type in 'about:config' without the quotesb. You will find a text box called Filter, type in 'auth' without the quotesc. You'll find an entry called network-automatic-ntlm-auth.trusted-urisd. Double-click on it. It will open a small input window.e. Enter the name of the website (usually if you're having issues with http://localhost), enter localhost and click OK. (You can enter multiple sites by separating them with commas)

No comments: