Installing PHP Under Personal Web Server - Installing PHP
(Page 3 of 4 )
Download Windows binary for the latest version of PHP. Once you've downloaded it, unzip it into a C:\, rename the folder to "php".
Open the PHP.INI-DIST file from C:\PHP folder, locate the following line:
;cgi.force_redirect = 1 We need to uncomment this line and change the setting to 0 as shown below to run PHP under PWS, do the necessary changes and save the file as php.ini in your windows folder (C:\windows on my computer):
cgi.force_redirect = 0 Configuring PWS for PHP There are two ways to configure PHP one to set up the PHP CGI binary and the other is to use the ISAPI module.
a) Using CGI Binary Open pws-php4cgi.reg file in a text editor (you shall find this file in the sapi folder inside the php folder)
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script Map]
".php"="[PUT PATH HERE]\\php.exe" Replace the [PUT PATH HERE] to the drive and folder where you have installed php eg c:\\php\\php.exe, so the new thing should look like
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script Map]
".php"="c:\\php\\php.exe" Note: Backslashes should be escaped.
Save the file and double click it in the windows explorer window to add this registry entry to your system alternatively you can run regedit, click Registry menu, select Import Registry File and select the file we just saved.
Open the Personal Web Manager, click advanced, from the list of Virtual Directories select
click Edit Properties check the execute checkbox and click OK. You can do the same process on any given directory you want to add PHP support to.
Don’t forget to restart you system.
Note: If you get the following error, you forgot to give execute permission on that directory.
b) Using ISAPI Module
Open pws-php4isapi.reg in a text editor (you shall find this file in the sapi folder inside the php folder):
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parameters\Script Map]
".php"="[PUT PATH HERE]\\php4isapi.dll"
Replace the [PUT PATH HERE] to the drive and sapi folder where you have installed PHP (eg c:\\php\\sapi\\php4isapi.dll).
Save the file and import this registry entry to your system also give execute permission on any directory, the steps to do that is show above (See Using CGI binary).
Testing PHP under PWS
Open your favorite text editor and create a text file and type the following in it:
<?php
phpinfo();
?>
phpinfo() is a PHP function which outputs a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment, the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License.
Save this file as test.php in C:\inetpub\wwwroots (your default PWS Web Root Folder)
Open you browser and type http://localhost/test.php in the address bar, click Go to see if you see output like the screen below to make sure PHP in configured and running properly.
If the source code appears in the browser and not the output we are expecting, then PHP has not been properly installed or PWS does not recognizes PHP files, please make sure you have followed the instructions properly.Next: Conclusion >>
More PHP Articles
More By Jayesh Jain