The following post is for anyone running Windows Server 2008 and wants to host dynamic webpages using PHP scripting.
A couple of years ago I wrote a step by step process of installing PHP on IIS 6 on a Windows Server 2003. I wrote it because many of the steps they had online were sometimes incorrect, had gaps, missed steps that were crucial in setting up PHP. With the release of Windows Server 2008 Microsoft also updated it’s Internet Information Services to version 7. IIS7 has lots of new features and one of the in nicest addition is its ability to easily install PHP, compared to installing it on Windows Server 2003.
I wrote the following steps a year ago for documentation purposes. It should be the same process for Windows Server 2008 R2. I didn’t add screenshots because I’m assuming you’re familiar with Windows Server 2008’s GUI.
-Add the IIS Web Server role. Be sure CGI feature is installed.
-Download the PHP binary for Windows at http://windows.php.net/download/
-You will need to download and install Microsoft 2008 C++ Runtime (x86) if your OS is 64-bit
In this tuturial we’ll be using the zipped package rather than the installer.
-Unzip the contents to C:\php
-In C:\php directory rename one of the php.ini-xxxx to just php.ini
-In the php.ini file uncomment and set the vaule of the string to:
(To uncomment a line you just delete the semi-colon at the beginning of of line of code)
upload_tmp_dir = C:\Inetpub\wwwroot\uploads (you will need to manually create this ‘uploads’ folder)
date.timezone = america/tijuana (be sure to select your correct time zone. You can look up your time zones here: http://us3.php.net/manual/en/timezones.php)
If you plan to use extensions you will need to uncomment the line corresponding to the extension you want to use.
-Open your IIS Manager
-Select your host and click on Handler Mappings
-Add module mapping
-Fill out the Module mapping info
Request path: *.php
Name: php fastcgi
Make sure your php fastcgi is “enabled”
To test your php open up notepad and type in <? php phpinfo(); ?>
Now save the file as info.php. Place the file in C:\inetpub\wwwroot\
Open up your browser and point it to your info.php file (C:\inetpub\wwwroot\info.php
If all is successful you should see your PHP info and it’s configuration for your server.