Blog » Setup PHP on Windows Server 2008 R2

Setup PHP on Windows Server 2008 R2

Sometimes you'll have a need to install PHP on Windows to run a CMS or framework that requires it.

This guide applies to Windows 7 and Windows Server 2008 R2. Vista and Server 2008 should work, but you'll have to install IIS 7 Administration Pack to get FastCGI support in IIS.

In this case, I've used this guide as a base to get SilverStripe working on Windows, but the idea can be used for other applications like Drupal, and Wordpress.

I've also written an expanded guide on the SilverStripe documentation site if you're looking for more information.

Prerequisites

Install PHP

  • Download the latest stable PHP (VC9, x86) zip from http://windows.php.net/download
  • Extract zip contents to C:\php
  • Open PHP Manager for IIS and register C:\php\php-cgi.exe to enable PHP for IIS

Install sqlsrv extension for PHP (optional: if you need SQL Server support in PHP)

Install wincache extension for PHP

  • Download the latest wincache (for PHP 5.3, x86) from http://www.iis.net/download/wincacheforphp
  • Extract zip contents to a temporary location, such as C:\wincache
  • Copy php_wincache.dll to C:\php\ext
  • Open PHP Manager and go to Enable or disable an extension
  • Right click php_wincache.dll and hit Enable

Finishing up in PHP Manager

  • First of all, restart IIS to apply all changes
  • Go to Check phpinfo() in PHP Manager
  • Ensure that wincache and sqlsrv details can be found in the information
  • Go to Enable or disable an extension and disable everything, except for these:

php_curl.dll
php_gd2.dll
php_mbstring.dll
php_sqlsrv.dll (if you need SQL Server support in PHP)
php_wincache.dll
php_tidy.dll

  • Go to Configure error reporting and check Development machine (or Production machine if appropriate)
  • Go to Manage all settings and ensure the following are set to these values:

date.timezone = "Pacific/Auckland" (or whatever your timezone is from this list of support timezones in PHP.
post_max_size = 64M
memory_limit = 256M
upload_max_filesize = 64M

Restart IIS so all configuration takes effect.

Now you should have PHP up and running on Windows, and have a clean way of managing the configuration from IIS Manager, thanks to the very useful PHP Manager for IIS extension.