How to Install PHP on IIS 6 for Windows Server 2003
How to Install PHP on IIS 6 for Windows Server 2003
One of most popular development platforms on the web is PHP which powers many popular applications and sites such as Facebook, WordPress and Joomla. While most of these systems are ‘designed’ to be used on a Linux system running the Apache Web Server, you can deploy PHP applications via IIS 6 on your Windows Server 2003 system.
Configuring PHP
In order for Windows to run PHP code, the PHP binary files need to be copied to your system. No installation is required, however some configuration must be done in order for it to properly run. The first step is to download the PHP Windows Binaries and extract them (i.e. ‘C:PHP’). For IIS 6, the non thread safe binaries should be used.
Copy the ‘php.ini-production’ file from the extracted files paste it into the Windows directory. In the Windows directory, rename this file to ‘php.ini’.
Open the ‘php.ini’ file in Notepad and configure it as needed. Out of the box, the production configuration we copied is preconfigured for what the PHP Team feels is good for a production server. There are a few changes you will need to make to configure PHP for your IIS 6 system:
- Uncomment and set the key, cgi.force_redirect = 0
- Uncomment the key, fastcgi.impersonate = 1
- Uncomment and set the key, extension_dir to the ‘ext’ folder in the path PHP was extracted to (i.e. ‘C:PHPext’).
- Set the key, date.timezone to the time zone of your server (the URL on the line above this key lists the accepted values).
At this point, your Windows system can run PHP scripts from the command line using the ‘php.exe’ tool.
Installing the IIS 6 FastCGI Extension
In order for Internet Information Services (IIS) 6 to execute and serve PHP scripts, some additional configuration is required. In this guide, we will install PHP on IIS using the FastCGI interface which provides a good balance of stability and performance. Since FastCGI is not included with IIS 6 be default, we need to download and install it.
The FastCGI installer does not require any configuration, however once the FastCGI extension is installed we need to configure it to run PHP.
Open the file ‘C:WINDOWSsystem32inetsrvfcgiext.ini’ in Notepad and find the ‘Types’ section and enter the configuration information:
[Types]
php=PHP
[PHP]
ExePath=C:PHPphp-cgi.exe
InstanceMaxRequests=5000
EnvironmentVars=PHP_MAX_REQUESTS:5000
Revise these values as needed according to your environment, but it is important that all of settings have the correct values. Once you are finished, save this file.
Configuring IIS to Run PHP via FastCGI
With both PHP and FastCGI installed and configured, all that is left is to set up IIS 6. When you open the IIS Management Console, under the Web Service Extensions make sure the “FastCGI Handler” is set to allowed.
Next, go to the Properties settings for the Web Sites group.
On the “Home Directory” tab, click the “Configuration” button.
Add a mapping for files with the .php file extension with the executable set to the FastCGI extension DLL.
Once you have applied all the changes, restart IIS.
Testing PHP
At this point, your server is ready to go, but just to be sure we can confirm your PHP setup through IIS pretty easily. Create a text file in the directory ‘C:Inetpubwwwroot’ named ‘phpinfo.php’ which simply contains the line:
<?php phpinfo(); ?>
Finally, browse to the address: ‘http://localhost/phpinfo.php’ on your server and you should see the PHP information page. If the page loads successfully, PHP is now up and running on your machine.
Conclusion
Once you have PHP up and running on your Windows system, you can take advantage of the multitude of PHP based applications available as well as develop and deploy your own.
Links
Download PHP Windows Binaries (non thread safe)
- ۹۳/۰۲/۲۴