At the Intersection of PHP and Microsoft
I started working on some of the posts that I've promised, but I quickly realized I should cover the basics first. So, in this post I’ll cover the requirements, options, and instructions for installing PHP and configuring Internet Information Services (IIS). (My knowledge of the Apache web server is not extensive, so I’ll point Apache users to these tutorials: Using Apache with Microsoft Windows and How to Install and Configure PHP 5 to Run with Apache on Windows.)
I suggest reading through the entire post before starting to install PHP. I will cover how to use the Web Platform Installer (WPI) and how to install PHP manually. The WPI has the advantage of being easy, but is less flexible than a manual installation/configuration. On the other hand, a manual installation is flexible, but requires you to make more choices (and understand your choices).
The easiest way to get started with PHP on Windows is by using the Web Platform Installer (WPI). This tool can download and install PHP and configure IIS automatically. It can also install SQL Server Express and Web development tools, which I recommend doing. (I’ll talk more about installing and configuring database access in a later post.) If you already have some components of your Web development environment set up, you can use the WPI to install the missing components. You can download the WPI here: http://www.microsoft.com/web/downloads/platform.aspx.
Note: The WPI can be used with the following operating systems: Windows 7, Windows Vista, Windows Vista SP1, Windows XP SP2+, Windows Server 2003 SP1+, Windows Server 2008, Windows Server 2008 R2. If you are not using one of these operating systems, skip this section.
Once you have downloaded the installer and it has started, click the Web Platform tab to begin selecting the components you want to install. Under each component, click Customize to select options. I’ll walk through the options for each component below.
Web Server: There are lots of options for configuring your Web server. Proper configuration really depends on what the server will be used for. For more information about an option, click the information icon next to it in the tool, and remember that you can always change these settings later.
Frameworks and Runtimes: You only need to select PHP. Note that (as of this writing) PHP 5.2.12 is installed. If you want the benefits of Windows Cache Extension for PHP, select it. You don’t need to install any of the .NET Framework unless you expect to use it.
Database: Strictly speaking, you don’t need to install a database with PHP. But, practically speaking, you probably will. The selections below show my recommendations for installing SQL Server Express, the SQL Server Driver for PHP, and SQL Server Management Studio Express.
Tools: If you have a favorite IDE for PHP, you don’t need to install any of the available tools. If you don’t have a favorite IDE, or you’d like to try Visual Web Developer 2008 Express, select it.
Note that you can click on the Web Application tab and choose from several popular Web apps to install along with your PHP/Web server installation. If you select an application that requires a MySQL database, the tool will install it for you.
After you have selected your components, click Install. The WPI will download, install, and configure everything for you, including making the necessary changes to your php.ini configuration file.
I really can’t do a better job of explaining how to install PHP and configure IIS than you can find on the PHP website: http://www.php.net/manual/en/install.windows.php. Depending on your web server, these are the instructions to follow:
· IIS 7.0 and Later
· IIS 5.1 and 6.0
· Apache 1.3.x
· Apache 2.x
These instructions do not include information about setting up a database. I’ll cover this in a later post.
Installing PHP and configuring IIS manually will give you more control over exactly what you install and how it is configured, but it also requires that you make more decisions in the installation process. For example, when you install PHP manually, you are not limited to one version of PHP (as with the WPI). However, you have to decide which version of PHP is right for you. Fortunately, there is some good guidance about which version to choose on the download site, http://windows.php.net/download/:
Which version do I choose?
If you are using PHP with Apache 1 or Apache2 from apache.org you need to use the VC6 versions of PHP.
If you are using PHP with IIS you should use the VC9 versions of PHP.
VC6 Versions are compiled with the legacy Visual Studio 6 compiler.
VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64) installed.
Do NOT use VC9 version with apache.org binaries.
Also note that you should choose a non-thread-safe version of PHP for running IIS with FastCGI.
I hope this makes installing PHP on Windows easier for you. As always, questions and comments are welcome. (Please let me know what information is missing here…)
Share this on Twitter
Additional Resources: http://php.iis.net/, http://www.iis.net/ConfigReference,