Monday, 12 August 2013

Running PHP on 64-Bit Windows server 2003 R2 IIS

Running PHP on 64-Bit Windows

posted in 64-Bit WindowsIIS 6.0PHP |
I have recently started working on 64-bit Windows servers more often and thought I’d share some of my experiences along the way.
One of the issues I encountered was with the installation of PHP on a 64-bit Windows Server 2003 R2 machine. The server already had IIS 6.0 installed so I downloaded the latest distribution of PHP and installed it in the usual way as described here How To Install PHP on IIS 6.0

The installation of PHP on IIS is pretty straightforward so I was a little surprised when I was presented with the following error after browsing to http://localhost to check that everything was working.
Fig. 1
The first thing I always do when troubleshooting a problem is to make Internet Explorer give me a useful error message to work with. You can do this by clicking Tools | Internet Options | Advanced and then unticking ‘Show friendly HTTP error messages’ as shown here
Fig. 2
Once this was done I was able to see the actual error message being returned to the browser as shown here :
Fig. 3
Since my previous experience with 64-bit Windows and IIS was pretty limited I hadn’t encountered this particular error message before but a quick scan through the various newsgroups and Google quickly revealed the cause of the problem.
Without realising it I was trying to load a 32-bit application (in this case PHP) inside a 64-bit worker process and it was this that was causing the 500 Internal Server error I was seeing in my browser. Since the latest Windows distribution of PHP from www.php.net is only available in 32-bit version you need to configure IIS to run in 32-bit mode if you are using a 64-bit version of Windows.
In order to configure IIS to run in 32-bit mode you need to execute the following command :
cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1
This will set the Enable32bitAppOnWin64 metabase property to True as shown here :
Fig. 4
It is important to note that IIS 6.0 does not support running in both 32-bit and 64-bit modes at the same time - in other words this is an ‘all or nothing’ system wide setting which affects all IIS web sites on the server, so if you need to run both 32-bit and 64-bit applications in IIS you will either have to locate them on separate machines or run them all in 32-bit mode.
Fig. 5
Now, when I browse to http://local/index.php the page loads correctly and I can run PHP applications on my 64-bit IIS server.
Post a Comment

Analytics and Statistic

Blog Archive