PHP on Windows has come along way in the past few years. It used to be a chore to get PHP to work properly on IIS. Not so, anymore.
In the past I’ve recommended PHP ISAPI for IIS when using threaded applications and accelerators like eAccelerator, xCache and APC. APC now includes support for FastCGI (Non-Thread Safe). To install PHP 4 – 5.2.x ISAPI, see my previous post: How to install PHP ISAPI on Windows 2008 IIS7 x64.
With PHP 5.3.x, the ISAPI dll has been removed for Windows. In order to use it, you’ll need to compile it yourself. There is a big push to use FastCGI on IIS, and with good reason – the performance has increased dramatically. Since most web applications (blogs, forums, CMS) do not require a Thread Safe install of PHP, FastCGI is the fastest and most stable option around.
PHP 5.3 for Windows is now compiled with either VC6 or VC9. VC9 should be used with IIS and VC6 should be used with Apache 1 or 2. For the VC9 versions you will need the Microsoft 2008 C++ Runtime (VC x86, VC x64, even though you are installing 32-bit PHP, install the correct version of VC++ for the version of Windows that you have).
When installing multiple versions of PHP with PHP Manager, each install can have a different PHP.ini and set of extensions installed and enabled. Within IIS, you can have a different version of PHP enabled for each site.
1. Download and Install PHP Manager for IIS 7/7.5. (http://phpmanager.codeplex.com/releases/view/59970) Even though PHP is 32-bit, install the version of PHP Manager that matches your install of Windows (x86 or x64).
2. Download and Install PHP 5.3.x for Windows VC9 (Non-Thread Safe). (http://windows.php.net/download/) You can use the installer or zip package. I’d recommend using the installer package if this is your first install, as it will set the PATH for your PHP install in Windows. If you are adding a second version or upgrading PHP, download the zip package and simply unzip it. If you plan to use multiple versions of PHP at the same time, I’d recommend naming your directories with the PHP version, ie: C:\php_5.3.5\.
3. In PHP Manager (IIS Manager -> Server Name -> PHP Manager), click on “Register New PHP Version” and browse to where you unzipped the PHP files. Select the php-cgi.exe file and click OK. Once you have registered the PHP module, you’ll need to configure the PHP.ini. This can be done in Notepad or within PHP Manager (Manage All Settings). For most basic installs, the default PHP.ini will suffice. If you are using a MySQL database, you’ll have to enable the MySQL or MySQLi extension. Go to IIS Manager -> PHP Manager -> PHP Extensions -> Enable or disable an extension. Click on php_mysql.dll and/or php_mysqli.dll and under Actions on the right side bar, click Enable.
4. If you are using Windows x64, you’ll need to set your application pool settings to allow 32-bit PHP to function. If you are using 32-bit Windows, skip this step. In IIS Manager -> Application Pools -> Right-Click on the website’s application pool (or Default if you haven’t set one up yet) and select Advanced Settings. Set “Enable 32-bit applications” to TRUE. Click OK. This spawns the App Pool in 32-bit mode, so if you have other modules that need to be run in 64-bit mode, best to separate the website into two App Pools: one 32-bit and one 64-bit.
5. If you want to install multiple versions of PHP, all you need to do is register each version using PHP Manager. You can click on each individual website and select a specific version of PHP to run. Remember to modify the PHP.ini of each version you register. If you get CGI errors when trying to view a webpage, make sure cgi.force_redirect = 0, or it is commented out in the PHP.ini.