Tech Tip: PHP on IIS 7

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
Module:   FastCGIModule
Executable:   C:\php\php-cgi.exe
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.

Host jad and cod files on Windows IIS

For those of you who have Blackberry devices you may have downloaded applications over-the-air (OTA). Blackberry devices uses a .jad file to download OTA apps by pointing its browser to that file. OTA apps actually consists of two file types .jad and .cod. The .cod files are actually the content of the application and the .jad files points to it.

If you plan to host your own OTA files on a Windows IIS server you’ll need to make some changes to your web server to process those .jad and .cod files.

You will need to access Internet Information Services and right-click on Web Sites and select properties. Select the HTTP Headers tab and click on MIME Types. Here you will add two MIME Types:

Extension: jad
MIME type: text/vnd.sun.j2me.app-descriptor

Extension: cod
MIME type: application/vnd.rim.cod

You may need to restart IIS once you’ve added the MIME types. Open the command prompt and type in “iisreset” (minus the quotes).

Vista x64 (part 2)

After fiddling around with the 64 bit version of Vista I found it to be very stable. Speed wise it’s just as fast as the 32 bit version. Fortunately the architecture of recent CPUs of Intel and AMD they’re able to process 32 and 64 bit code simultaneously. So having a 64 bit OS doesn’t mean you’re stuck using only 64 bit applications. After installing a 64 bit version of Vista you’ll see two ‘Program Files’ folder and one will be designated as ‘Program Files (x86)’. When installing your old 32 bit application they will be installed in the Program Files (x86) folder. This keeps your 32 and 64 bit application seperate.

Many of the usual programs worked fine. Office 2003 and 2007 worked without any problems along with Avg Anti-Virus Free, Winamp, WinRAR, PowerISO, VMware Workstation, and Pidgin. The only application I had any issues with are homebrew apps or compiled binary files (.exe). These applications would throw errors and would not execute. Some application can still work if you install a compatible framework in which the 32 bit application can run on. But for me it’s not a big problem because I run VMware Workstation. I can have a virtual 32 bit OS and run those application on that instead. Vista x64 comes with a host of native 64 bit application such as it’s games, Windows Media Player, and Internet Explorer. These native applications works right out of the box. At this time the 64 bit version of IE is limited because the lack of compatible plug-ins like Adobe Flash player aren’t available yet. So to get full internet browsing capabilities the 32 bit version of IE is still available.

Having Vista x64 on my work computer would be fine since most of my computing involve email, remote accessing, and running multiple VMs. But on my personal desktop I ran into some issues. My desktop system is also my media center. One of the big disappointments of the SP1 is that Vista’s Media Center remains unchanged since Vista’s initial release (more on this later). Vista x64’s Media Center is a native 64 bit application and its backbone runs on the 64 bit Windows Media Player. Many of my videos are encoded in different formats and it requires several different codecs to play. Unfortunately I can’t play any of my videos because 64 bit codecs aren’t available. The ones that are available are in beta stages and still doesn’t work.

When Vista was first released my number one reason to upgrade was to use the new Media Center. XP’s 2005 Media Center worked great, but there were many things it could have improved on, and I thought Vista was the answer. Too bad it was only wishful thinking. Vista’s Media Center’s interface is counter-intuitive compared to its predecessor. The media handling is done by Window Media Player. WMP is so limited that that the only type of videos it can play is mpg and wmv videos. It’s not much of a media player without third party codecs. So the 64 bit version of Vista media center is even more crippled than it’s 32 bit counterpart.

Overall there are more positive aspects of Vista x64 than there are negatives. If you have a recent CPU and chipset such as a Core 2 Duo and the Intel 965P the 64 bit OS is capable of addressing more than 4GB of RAM. This will benefit applications that require a large amount of memory. Video/Image editors and CAD users will greatly benefit from this. Overtime 64 bit applications will become more popular and in theory it should be more efficient and faster than their 32 bit versions. If you’re looking to jump into the 64 bit scene now is a good time to check it out. For some it can be used as their main OS on a daily basis. But before you switch make sure there are 64 bit drivers for all your hardware. Vista 64 bit OS requires signed drivers so if your hardware manufacturer does not have those drivers available your device(s) will not work.

Vista x64

vistasp1

Last year when Vista was release to the masses I had already been using the Vista RTM version for a few months. I even wrote a little review about my experience. In short, the new OS was visually appealing but had too many things wrong with it such as bugs, incompatible software and not enough drivers were available. I ended up uninstalling Vista and reinstalled Windows XP and have not used it since except for when I’m troubleshooting a Vista system at work.

It’s been a little over a year, about 14 months, since Vista’s release. I got my hands on a copy of a Vista RTM with SP1. SP1 was the answer to all the nay-sayers who didn’t want to use Vista. Many online publications have already done benchmarking tests and SP1 was no faster than the orginal RTM release. In fact some showed SP1 as being slightly slower. I wanted to see the results for myself so I set up Vista w/SP1 on a couple of virtual systems on VMware. Using Vista on VMware probably didn’t provide much of a guage to show the difference with the new SP1, So I decided to install Vista Ultimate 64 bit version on my primary desktop system. Before formatting and reinstalling a new OS I always backup all my files and I download all the drivers needed for the new OS. I was a bit worried because I’ve never installed or used a 64 bit OS. I expected many things to go wrong with the installation.

I booted off the Vista RTM /w SP1 DVD and installed it. Everything went as normal as the regular Vista sans SP1. It took about 25-30 minutes for the entire install. I finish the installation and logged on to Vista with my username and password. The first thing I always check after I install a fresh copy of Windows is check the Device Manager. One of the most daunting task for installing Windows is finding yellow exclaimations and unknown devices listed in the Device Manager. That’s where downloading the needed drivers before the OS change can save you time and headaches. In this case after the installation there was only one yellow exclamation in the device manager and it was for my USB XBOX HD DVD drive. Running the Windows update fixed it and my Device Manager window was all clean. I was amazed it had drivers for my motherboard devices as well as my dual Hauppauge tuners.

The year between my first Vista install til now there has been a ton of hotfixes and driver updates. This Vista installation couldn’t be any easier. My next test will be evaluating my 32-bit applications and see how it run on this 64 bit Vista.

[To be continued…]