22nd October 2007

Running PHP on 64-Bit Windows

posted in 64-Bit Windows, IIS 6.0, PHP |

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.

This issue is discussed in this KB article Windows Server 2003 SP1 enables WOW64 compatibility for 32-bit Web applications in IIS 6.0 and also here How to switch between the 32-bit versions of ASP.NET 1.1 and the 64-bit version of ASP.NET 2.0 on 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.

This entry was posted on Monday, October 22nd, 2007 at 3:23 pm and is filed under 64-Bit Windows, IIS 6.0, PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

There are currently 30 responses to “Running PHP on 64-Bit Windows”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On November 22nd, 2007, Peaboy said:

    I was wondering why not use a 64bit version of PHP. I was trying to follow your steps using this version of php and its not working. I get a 404.


  2. 2 On November 22nd, 2007, Peaboy said:

    Never mind… when I ignore the steps about adding .php application extension usng the adsutil and do it with the UI it all works fine… 😉 Key thing is here is HAVE to run IIS in 64 bit mode if you’re alos running Exchange 2007 on the same server so is KEY to have a 64 bit PHP.

    Thank for the steps and sharing though!!

  3. 3 On December 11th, 2007, John said:

    This is a great article, I was wondering what’s wrong with my system when I keep on getting the “Internal Server Error” good thing I saw this page. Thanks!

  4. 4 On January 2nd, 2008, que0x said:

    great post, here is my experiance : http://blahblah.webunusual.com/index.php/2008/01/01/x64-fashioned-speed-iis-on-x64-php-and-fastcgi/

    hope it helps

  5. 5 On May 16th, 2008, Nimalakanth said:

    That works fine for me…
    Being a developer, Is the mail is not enabled in the 64bit Windows version… I am keep on trying with lot of codes, but still, i couldnt able to send mail from my server through php code. As it stops in between… Any suggestions for this problem.

  6. 6 On August 7th, 2008, markwilson.it » Installing PHP 5 on IIS 6 said:

    […] If you are running on 64-bit Windows there are some extra steps in order to avoid an HTTP 500 Internal server error or the message %1 is not a valid Win32 application. It seems that this is caused by trying to load a 32-bit application (in this case PHP) inside a 64-bit worker process (as described in Microsoft knowledge base article 895976). To resolve this issue, enter cscript adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1. adsutil.vbs is one of the scripts installed into the wwwrootAdminScripts folder but if you have removed it to secure the server (as I had), then it may be temporarily copied back to the server from another IIS installation. […]

  7. 7 On October 27th, 2008, 64位Windows Server如何使用PHP | Nocoo.Weblog | 李征(Zheng Li)的个人博客 said:

    […] Anyway,Google到一个方法,Running PHP on 64-Bit Windows,我试一下。 其实解决64位兼容性问题一般也就两种方式:换64位PHP,或者让IIS在32位方式下运行。下面介绍一下如何让64位系统的IIS在32位模式下运行。 […]

  8. 8 On November 10th, 2008, jumbo said:

    it does not works for me. i see SERVICE UNAVAILABLE in my browser =(

  9. 9 On November 23rd, 2008, MalcolmW said:

    Jumbo – I had the same problem. It is caused because the ASP.NET 2.0 ISAPI filter is pointing to the 64-bit version so causing a conflict with the 32 bit operating mode.

    What you need to do is go to the Properties for Web Sites / ISAPI Filters and point the ASP.NET 2.0 filter to the 32-bit version: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll

  10. 10 On June 18th, 2009, vijay kadadi said:

    as per Malcolm W said: the solution but i dont usnderstand how.Cox on my 4 bit windows2003 server..in IIS6.0 already DotNet site is configured with 64 bit framework2.0 and now i installed/configured the PHP5.4 with IIS6.0 and then enable the 32 bit mode on IIS6.0(64bit) using
    (cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1) this command but now that php site is not working error message is Service is not available.
    So can i rollback to 64 bit enable IIS and will try with 64 bit PHP application using this URL:-http://www.fusionxlan.com/PHPx64.php

  11. 11 On June 23rd, 2009, Justin said:

    Good article. This all goes fine for me up until the point I run: cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

    The error: %1 not a valid win32 app turns into:

    Service Unavailable. I have tried every fix on google for this including messing with the application poll but still not solution. Arg!!

  12. 12 On July 9th, 2009, Rodrigo said:

    Very Good article. And MalcolmW you saved me. I was having the same problem that jumbo and you tip worked perfect..

  13. 13 On August 26th, 2009, Bruno said:

    Thank you for this information, it works !

  14. 14 On September 18th, 2009, Greg Richardson said:

    WOW! I blew about 3 hours, and lost fist-fulls of hair before I stumbled on your solution. Thanks!

  15. 15 On October 22nd, 2009, Brice said:

    Most excellent. I just started having this issue last night and was looking for the answer. Everything that I had run across on the Internet was telling me that it was a user permissions error or something to the degree. With everything else setup like it was suppose to be, setting the IIS to operate in in 32bit fixed it right away. THANK YOU!

  16. 16 On October 22nd, 2009, Brice said:

    Even the Microsoft website ( http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/0aafb9a0-1b1c-4a39-ac9a-994adc902485.mspx?mfr=true ) did not work. **As a side note**

  17. 17 On November 9th, 2009, jawad said:

    after the localhost following error is shown

    Directory Listing Denied
    This Virtual Directory does not allow contents to be listed.

  18. 18 On January 8th, 2010, Gdhar said:


    I have Windows 7 x64 and my web application (website) is also a x64 compatible (created using VS2005). When I try to add it; it gives me “%1 is not a valid Win32 application” exception.

    If I run the website with enable32bitapponwin64 True; application works perfectly as a x86 process but I want to run it as x64 process by setting enable32bitapponwin64 False since my app is x64 compatible.

    I tried this command; but still no luck.

    %SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i

    Please suggest the solution. Am I missing any step?


  19. 19 On March 30th, 2010, Rao atif said:

    I tried to install php on win server 2003 64 -bit but i can’t c it in my browser but on command prompt i can c the php info page.
    I tried all what i know.
    Any solution

  20. 20 On May 6th, 2010, Anil said:

    You’re awesome, keep posting. i’m still new to all these and it helps me a lot reading your blog.

  21. 21 On May 28th, 2010, nons said:

    I am currently running MS Exchange on a 64bit Win 2003 server using IIS6. I want to install PHP & MySql but if i change IIS6 from 64bit to 32 bit will it affect the emails hosted?

  22. 22 On May 29th, 2010, Paul Lynch said:


    I haven’t tested this scenario so I would strongly recommend that you test this first before you make any changes to your production environment.


    Paul Lynch

  23. 23 On June 18th, 2010, Sohail said:


    1) Download PHP64 version from this link (http://icrontic.com/forum/showthread.php?t=46956)
    2) Extract main zip file and find another file “php-5.2.5-x64-2007-11-12.zip”
    2) Extract “php-5.2.5-x64-2007-11-12.zip” and copy the contents of “php-5.2.5 (x64)” into C:\Phpx64\
    3) Pint your web services extension to C:\Phpx64\php5isapi.dll
    4) Go to properties of ” Web Sites” Directory in IIS and then into HOME DIRECTORY ->CONFIGURATION -> Add or edit .php extension here. You would need to point to the same dll “C:\Phpx64\php5isapi.dll”


    Please comment if it works!

  24. 24 On July 4th, 2010, sashabe said:

    The Sohail’s solution works for me as well!

  25. 25 On September 14th, 2010, Miaou said:

    Yep it’s work perfectly for everydoby in my situation :

    Microsoft Server 2008
    IIS Server

    Big Kisses Sohail’s

  26. 26 On October 26th, 2010, %1 is not a valid Win32 application PHP & Windows Server 2003 64bit | Ycsoftware.net said:

    […] References http://www.iisadmin.co.uk/?p=14 PHP, […]

  27. 27 On November 15th, 2010, cmmitw said:

    Awesome, thank you!

  28. 28 On December 30th, 2010, BC said:

    Your solution not workable for me which my pc is win7 pro 64bit,anyway thank you. At the end I found the solution in other site. I also post the solution on my blog. Happy New Year.

  29. 29 On December 6th, 2011, Lỗi “%1 is not a valid Win32 application” khi truy cập IIS trên Windows 64bit « Tiny Expert said:

    […] http://www.iisadmin.co.uk/?p=14 […]

  30. 30 On October 25th, 2015, PHP5.3 hangs IIS6 on windows2003 64bit - Tech Magazine said:

    […] The need is I want my existing website(classic asp) to include a wordpress blog (mu) with friendly url. So want to install it as a subdirectory to the IIS website. I have single IP allocated. Could not get the 32 bit php environment working as per IISADMIN […]

Leave a Reply

You must be logged in to post a comment.

  • Calendar

  • May 2018
    M T W T F S S
    « Sep