Tuesday, May 6, 2008

Configuring PHP5 using IIS 5.1.

Ok, I had a really bad time on installing php on windows xp sp2 using IIS 5.1. Its really annoying for new users. If you are a new user or learner of php, here is the step by step guide for installing and configuring PHP5 using IIS 5.1.

->Extract the php files in any temp folder. Then copy all files from the folder in c:\php5 directory. If it does not exist then create it.

->Now get your windows xp sp2 cd and place it in your cdrom drive. If the cd auto runs then click the option for 'installing additional components'. Then check the components for 'internet information services' and 'network services'. This will install IIS 5.1 on your OS.

->To check wheather IIS is installed properly on your OS, go to your IE browser and in the address bar type, "http://localhost/" w/o quotes. If this opens something i.e., IIS default page and IIS help page then think that iis has been installed properly.

->Now in your php5 directory, rename php.ini-dist as php.ini and open it in the text editor like notepad.exe. Find the line doc_root= and replace it with doc_root = C:\Inetpub\wwwroot. Find extension_dir = and replace it with extension_dir = "C:\php5\ext". Find ;cgi.force_redirect = 1 and replace it with cgi.force_redirect = 0. Save the file and make a copy of this file and back it up and also place a copy of this file viz. 'php.ini' in the windows directory.

->Ok we are done with configuring the PHP. Its time to configure the IIS. Ok, open the IIS gui(start>control panel>performance and maintainance>administrative tools>internet information services(shortcut) or start>run>type"C:\WINDOWS\system32\inetsrv\iis.msc " ofcourse w/o quotes.

->Now a dialog will appear. Right click on "website" on the left window of the dialog. Click properties. An other dialog will appear called website properties.

In the ISAPI filter tab click add. Type filter name as PHP and executable as C:\php5\php5isapi.dll. Click ok once.

In the same dialog, go to "home directory" tab, click "configuration..." click add, type executable as C:\php5\php-cgi.exe and extension as ".php". If not, check the boxes for "script engine" and "check that the file exists". Click ok.

Then make sure that the check box for "chache ISAPI applications" is checked. Now click ok.

Now go to the tab "documents".Click "Add", then for "add the default document page" type "index.php". Then click ok. Move index.php on the top. Also make sure that "enable default document" is checked.

Now click ok till you return to the main dialog. Click the computer icon in the left window of the dialog that is your computer name.

In the menu bar, click "Action>All tasks>Restart IIS...". This is the safe way to restart the server. Thats all for configuring IIS.

->So you are now ready to script in php. Dont forget to save all your web pages in the directory C:\Inetpub\wwwroot.

Open your web page by typing http://localhost/yourpage.php.

->There is little possibility that I've missed something. If you have problems, then please let me know through my email which is "omkaronline@gmail.com"