PHP installation with extensions (mysql) for IIS7 in Windows Vista and Windows 7

When you download the PHP installer, it fails to install for Windows Vista. So you have to install it manually. Just download the zip file and extract it somewhere that you can remember.  Then you might want to manual installation instructions, but it won’t be correct for IIS7. Here is the guideline to install PHP to IIS7.

  1. Copy the php.ini to windows folder. enable the needed extensions by editing the file. Give rights for the file, to IUSR user, so that IIS can access the file.

  2. Run IIS Manager (inetmgr.exe)
  3. iis manager

  4. For the main site, click to ISAPI Filters, right click to add or actions add to php ISAPI handler with the filter name that you want. Just point to php5isapi.dll file which is the isapi filter.
  5. phpisapi.png

  6. Than come back to main site, and click to ISAPI and CGI Restrictions, and click add a restriction. For ISAPI and Cgi path select php5isapi.dll file and give a desired name for description. Also don’t forget to click “Allow extension path to execute”
    isapi
  7. Make sure that after adding, php is allowed from the ISAPI and CGI Restrictions window.
    isapicgirestrcit.png
  8. On ISAPI and CGI Restrictions page, right click to php and click to “Edit feature Settings”, from there you need to select both of them to enable php extensions to work, like mysql, mssql or ssl extensions specified in my.ini
    Feature Set
  9. Go to main site again, and click for the “Handler Mappings”. Click to add “Script Map”. For the request path type *.php, executable is php5isapi.dll  Name is Php
    addscript
  10. It will ask for the script map to add, just click to yes.
    Script Map
  11. Our php and extensions should work now, but we might want to add index.php file to look for a folder. From the main window, we click to “Default Document” and add index.php to the end of list.

That’s all for php and extensions to work.

46 Comments

  1. Mike says:

    I followed your instructions and I got the error message:

    Server Error in Application “Default Web Site”
    HTTP Error 500.0 – Internal Server Error
    Description: Calling LoadLibraryEx on ISAPI filter “C:\Inetpub\php\php5isapi.dll” failed

    Error Code: 0x800700c1

    Notification: Unknown

    Module: IIS Web Core

    Requested URL: http://localhost:80/brie/brie_index.php

    Physical Path: C:\inetpub\wwwroot\brie\brie_index.php

    Logon User: Not yet determined

    Logon Method: Not yet determined

    Handler: StaticFile

    Any ideas?

    Mike

  2. Singularity says:

    That might be the cause of the security features of Windows Vista. I just disabled them and make it look like Windows XP.
    Could you please try to give rights to anonymous or everyone Users, as far as IIS7 is OK with that for php folder (C:\inetpub\php in your case)

  3. Mike says:

    I’ve tried that already to no avail. I have also tried reinstalling php but still no luck. I am using php5.1.6 obtained from php.net.

  4. Singularity says:

    Actually installation of php won’t work. You need to get the zip file and somehow follow the php instructions combined by the instructions above.

  5. Phil says:

    I have followed the tutorial, except for one point. “Give rights for the file, to IUSR user, so that IIS can access the file.” I do not understand how to do this.

    I will try to launch phpMyAdmin and it will say: “cannot load mysql extension; please check PHP configuration”. I have MySQL installed and the extensions enabled in the php.ini in the windows directory. Any ideas?

  6. Andy says:

    I received the same problem as Mike

  7. Kien Pham says:

    Thank you! I got my mysql extension working finally.

  8. izwan says:

    could you please tell me how to enable mysql extensions?

    here is my php extensions directory:

    extension_dir = c:\php\extensions

    and here is the enabled list:

    extension=php_curl.dll
    extension=php_gd2.dll
    extension=php_ming.dll
    extension=php_mssql.dll
    extension=php_mysql.dll

    note that the other extensions is works! such as curl and gd…… but I didn’t see mysql list in phpInfo()

    can you please help me…..??

  9. SFera says:

    10x man .. U saved me .. it really matters the order u make the speps.. other tutorials didn`t work .. until I found u! 10x

    using Vista Ultimate x64

  10. boogie says:

    copy c:\php\dlls\*.dll c:\windows\system32 under administrator console should solve problem (admin console is invoked by start->accesories right click at “command prompt” and “Run as administrator”)

  11. boogie says:

    Also you will need probably another version of – ntwdblib.dll Version: 2000.80.194.0. Download from http://webzila.com/?wz=dll and search for it.

  12. [...] versions. If for any reason something goes wrong and you can’t get things to work check out Can Erten’s post which has some further steps including permission changes and ISAPI and CGI [...]

  13. DaveR says:

    If you’re still having issues with the mysql extension mysteriously not loading, try running PHP from the command-line When I did this, I had an alert display explaining that it could not find/load ‘MSVCR71.DLL’, and in the command-window a message saying it was “unable to load dynamic library ‘c:\inetpub\PHP\ext\php_mysql.dll’ – The specified module could not be found.”

    Ah ha! Searched around and sure enough that DLL was no where to be found on my system. I searched for it using the link that boogie provided, dropped it in my PHP folder and it worked. I had to restart the web-service to re-init the PHP isapi layer, but after so so so many hours of frustration, it worked … IT WORKED!

  14. Thanks! Very userful.
    I was looking for something like this.

  15. cagman says:

    i have succeded in instaling php on vista/IIS7, but the modules like mysql, openssl etc are not working, i have enabled them in php.ini, which is in windows folder, rights for this file are set to IIS_IUSRS, path to modules is correct

    but info(); says nothing about modules at all and they are not working, i dont know where to look for a mistake anymore

  16. cagman says:

    finally solved .. restart of app pool helped me

  17. cagman says:

    i have aslo added to php.ini ACL network service account

  18. Rifat says:

    Thanks . A great article . It helps me a lot.

  19. ash says:

    i am having problem.!!!!!!. looked everywhere but i couldn’t find any solution… if any of you can help me pls. help.. i’ve installed php with iis7. the works but everything else doesn’t. any ideas? thanx

  20. ash says:

    i am having problem.. looked everywhere but i couldn’t find any solution… if any of you can help me pls. help.. i’ve installed php on iis7. the “php phpinfo(); ”
    works but everything else doesn’t. i get 500 error.. any ideas? thanx

  21. void says:

    I did all the points as it was wrote and php still doesn’t work on iis 7.

  22. Siegeengine says:

    To get the extensions working I had to edit the php.ini extension_dir and set it to the path of the ext dir eg. “C:\Program Files\php-5.2.1\ext”
    Then i had to include the php path in the system environment path. You can find this in the properties of “My Computer” – Advanced System Settings.
    A good old reboot saw my phpinfo() page reporting my extensions all loaded. :)

  23. Brad says:

    Thanks, man!

  24. FreakTrap says:

    I found my solution here: http://bugs.php.net/bug.php?id=39163

    For those of us getting the ‘Calling LoadLibraryEx on ISAPI filter “C:\PHP\php5isapi.dll” failed’ error after an attempted manual install:

    1) *Start with a fresh IIS installation with both ISAPI filters and extensions enabled.
    2) Under the main settings [at the very top of your IIS Manager's hierarchy view, above Application Pools], add the following in this order:
    2.1) an ISAPI Filter for php5isapi.dll
    2.2) a ISAPI and CGI Restriction entry for php5isapi.dll
    2.3) a Handler Mapping for php5isapi.dll
    3) Go to the application Pools section.
    4) Right-click on Default Application Pool and select Advanced Settings.
    5) Set the second option [Enable 32-Bit...] to True.

    Now everything should work…

    * Also, it is important that your ‘Default Website’ not have any unique settings from the top-level configurations. This was causing my ISS to exhibit some pretty strange behavior, which is why I recommend that you first delete your default website and create a new one.

  25. O Myung Kwon says:

    Thanks a lot.
    Finally my php is working with IIs7.
    Thanks again, I had several problems, all my problems were came from confusing between global setting and local setting.
    As a begginer of IIS I havne’t realised that IIS7 has different setting option for global and local websites.
    After I flush away all setting and follow setting…it works.

    Don’t confused setting for global and local dude~~

  26. ahmad says:

    Dear,
    I tried all the way that available on Internet to install PHP and connect MySQL to it but it gives me this error when I tried to run and test the MySQL:
    Fatal error: Call to undefined function mysql_connect() in C:\inetpub\wwwroot\mysqltest.php
    Can anybody help me!!
    Thanks.

  27. Useful Eng. says:

    Hi,
    Thanks so much for this. If it helps anyone, if you are having problems, REVERT EVERYTHING AND RE-INSTALL AND CONFIGURE in the correct order. That is:
    1) remove all PHP
    2) remove completely your IIS webserver (from Windows features).
    Then,
    1) re-install the webserver, ensure it loads up .html pages
    2) install PHP
    3) configure your webserver for PHP as described in this article.
    Note: With newest IIS7, you do NOT need to explicitly manage the ISAPI restriction. In fact, you shouldn’t. Adding a script map will prompt you for this setting. So the one part in this article, #4: “come back to main site, and click to ISAPI and CGI Restrictions…”, NO LONGER APPLIES. For me, even the icon for those restrictions went away. The process is
    a) add the ISAPI filter
    b) add the script map

    Hope this helps. I was frustrated for hours before finally doing the clean re-install of everything. Good article tho; thank you.

  28. Sidha says:

    it works quite well.. except for one tiny but annoying thingy…

    since i’m only using IIS at home for developing stuf, the traffic on the server is like zero.. only me gets on it :) however, this results in that annoying message every time after 10 minutes or so… “IIS pocess worker has stopped working” .. well, duh!

    so.. how to get rid of that annoying message.. :-) ))

  29. Corlo says:

    I tried for so many ways to get PHP working on IIS7.

    The steps on this post are in the right order, it works!. Thanks for your help!

    Note: I had to uninstall IIS and PHP and I installed again, that solved the problem of extensions and some others.

  30. Thomas says:

    worked fine many thx

  31. tdldp says:

    Doesn’t work… u should test ur tuto under vista 64 bits before posting this…

  32. Can says:

    :) Well, I don’t have vista 64 but feel free to provide your own tutorial…

  33. Peter says:

    A reboot of the machine is required – not just the IIS web service. I’m using IIS 6.0 on W2K3 server, but it took me a few days of trying all sorts of things and searching the web far-and-wide before I just rebooted the server. Then the mysqli extension finally loaded. It bears repeating since most guides and instructions fail to mention it – REBOOT WINDOWS.

  34. Mark says:

    Thanks FreakTrap for the bug fix to get it to work on x64! Life saver!

  35. Max Kima says:

    Thanx! I’ve done it!

  36. GregoJDK says:

    Hi…
    I´m From Brasil… and my Inglish is very bad… but i try…

    THIS IS A VERY GOOD SOLUTION… WORK REALY OK…
    BUT… REMEMBER… REBOOT YOUR MACHINE !!!

    Thanks all

    Grego.

  37. donut says:

    Sweet! This worked like a charm! Thanks for posting!!

  38. Rich Carless says:

    Hi,

    One important step which isn’t mentioned on this tutorial is that after following the steps you _have_ to restart the web server inorder for the configuration to take effect.

    Cheers
    Rich

  39. Darren Ricketts says:

    Hi Folks

    Just spent a few hours looking at the same problem running vista business, iis7 etc. The final piece of the jigsaw was that I had actually saved the php.ini as php.ini.ini which is a basic mistake for a novice like myself but something that isn’t explicit in the tutorials.

    When you take the php.ini.recommended file, amend and save as you should also remove the .ini from the file name before saving.

    Look in the folder where you have saved your php.ini file and if it is named php.ini simply remove the .ini and retain php – check the file properties before changing the name and you should see that .ini.ini appears. Restart IIS. This worked for me and now phpMyAdmin is running perfectly.

    Cheers
    Darren (aka dufus)

  40. Paul says:

    This post has staying power! Thanks it helped me out a lot!

  41. Jay says:

    I got this error while open php page:

    HTTP Error 500.0 – Internal Server Error
    Description: Calling LoadLibraryEx on ISAPI filter “E:\SOFT_INSTALLED\php\php5isapi.dll” failed

    Error Code: 0x8007007e

    Notification: Unknown

    Module: IIS Web Core

    Requested URL: http://localhost:80/test.php

    Physical Path: C:\inetpub\wwwroot\test.php

    Logon User: Not yet determined

    Logon Method: Not yet determined

    i strictly follow ur steps to configure PHP with IIS7,but the error is here.

    i have extracted php from zip file in E: drive.u told that this error is for security reasons. how can i set permissions to this php directory?

    I strictly followed ur steps but the error is still here.

    i have extracted PHP file from zip to E: drive and i have windows Vista SP1 OS.

    what is problem???

  42. crystal says:

    hello……… may any one tell me the proper method of installing the XAMP (php, mysql, apache server) in windows VISTA? i tried all methods that are given above……. but failed . So tell me

  43. Jony says:

    install IIS.
    Install PHP
    Goto Handler Mappings
    Click Add Module Mapping…
    Request Path: *.php
    Executable: C:\Program Files\PHP\php-cgi.exe
    Name: PHP_via_FastCGI
    Select Request Reastiction: Mapping None, Verbs all Verbs, Access None.

    I Think This May Help You..
    Regards: jony4fun@in.com

  44. Jony says:

    some1 plz inform me “how to install mySQL on Vista”.
    Config:
    C:/ : 40GB. Free Space: 9GB.
    RAM: 3GB
    OS: Vista Service Pack 1.
    or anything ami i missing?
    plz mail me @ jony4fun[at]in.com

Leave a Reply