December 17, 2009

Installing php4 and php5 on windows

Running PHP4 and PHP5 on Windows
============================

We can make php4 and php5 run on windows in two ways, either we can install php4 and php5 in CGI mode or we can install php4 in ISAPI and PHP5 in cgi mode.
Installing PHP4 and 5 in ISAPI mode is not feasible as both will be using the same php.ini in the windows path.

Setting up PHP to run in CGI mode
-------------------------------------------

This is the easiest way to have PHP 4 and PHP 5 running on the same server. When running in CGI mode, PHP can check the PHP installation directory for a php.ini file. Here are the steps to take to configure PHP in CGI mode:

1. If you have previously had PHP on this server, ensure that there are no php.ini files in your windows directory, or any php dll’s

2. Unzip the PHP4 ZIP file to C:\php4

3. Make a copy of php.ini-recommended, and rename it to php.ini, leaving it in your PHP4 directory. Open it in notepad, and search for the area that looks like this:
; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this on by default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; cgi.force_redirect = 1
Change the last line to disable force_redirect, so that it looks like this:
cgi.force_redirect = 0
Make any other modifications that you wish to, and save the file.

4. Now unzip the PHP5 zip to C:\php5, and once again make a copy of php.ini-recommended called php.ini. Again, open it in notepad and peform the same change as for PHP4 in step 3

5. Ensure that neither of the PHP directories appear in your windows path

Setting up PHP to run in ISAPI mode
----------------------------------------------

ISAPI often gives better performance than CGI mode, however it causes a problem when running both PHP4 and PHP5. This is because you normally have to have php.ini in your Windows directory, and both PHP4 and PHP5 would use the same php.ini (which would not work). The instructions below will allow you to get around this problem.

1. If you have previously had PHP on this server, ensure that there are no php.ini files in your windows directory, or any php dll’s

2. Unzip the PHP4 ZIP file to C:\php4

3. Make a copy of php.ini-recommended, and rename it to php-isapi.ini. Place this file in your windows directory. Open up this file and search a line such as:
extension_dir = “./”
In this line, enter your PHP4 extensions directory as below and save the file:
extension_dir = “C:/php4/extensions/”

4. Now unzip the PHP5 zip to C:\php5, and once again make a copy of php.ini-recommended called php-cgi-fcgi.ini and place this in your windows directory. Open up this file and search for the extensions directory line again. Place the PHP 5 directory in this time, like this:
extension_dir = “C:/php5/extensions/”

5. In the same php.ini file, search for the area that looks like this:
; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this on by default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; cgi.force_redirect = 1
Change the last line to disable force_redirect, so that it looks like this:
cgi.force_redirect = 0
Now save the file.
6. Ensure that neither of the PHP directories appear in your windows path (they shouldn’t do unless previously put there)

As you have done this much now the part we have to do is to set the environment variable and intgrate it with IIS.

You can set the environment variable for php by right clicking my computer-->properties-->advanced-->set environment variable then in the path section add the path of the php
Now inorder to integrate the .php extension in IIS just add the extension for php in webservice extensionof IIS and then select thelocation for .exe file in the case of CGI and select the location of the corresponding .dll file in the case of ISAPI

No comments:

Post a Comment