Saturday, December 13, 2008

Faulting application httpd.exe, faulting module php5ts.dll

Trying to setup a web development environment on a Vista machine, pretty much the same way I've done it a few time before, although maybe with newer versions - Apache HTTP 2.2.10, PHP5 5.2.8 and MySQL 5.1. When trying to access phpMyAdmin, it was crashing with the following error in Event Viewer:
Faulting application httpd.exe, version 2.2.10.0, time stamp 0x48ef9351, 
faulting module php5ts.dll, version 5.2.8.8, time stamp 0x493d75fc, exception code 0xc0000005, 
fault offset 0x00009fe6, process id 0x18c, application start time 0x01c95d543b01222a.
I thought initially that all these new versions are not working properly together, googling for php5ts.dll I found this used to happen to other people with older versions. While reading a post with few suggestions, I remembered that in previous setups (on XP) PHP wasn't able to connect to MySQL until PHP\libmysql.dll was found somewhere in the PATH - some people were suggesting to copy it in various locations, like %WINDIR%\system32 or Apache\bin. Personally I don't like that, copying files around has the disadvantage that if you update PHP later and it's coming with an updated version of this file, you will have to remember to copy it again, otherwise you may run into problems (yes, I've done it before, but not anymore :-). The best solution is to add C:\Program Files\PHP to the system PATH, so that when you update PHP it will pick up the new dll.

Just to confirm, I ran ProcMon and set it to filter on httpd.exe process and for path libmysql.dll. I noticed that it was finding the libmysql.dll in MySQL\bin folder, which may be newer and incompatible with the PHP mysql extension. Adding the PHP location (C:\Program Files\PHP5 in my case) in the PATH system variable, before the MySQL\bin entry and restarting Apache web server solved the problem.

37 comments :

  1. Excellent post. I had the same problem, with nearly exactly the same log issues. Your solution fixed me up right away by just switching php location to appear before MySQL\bin instead of after.
    Thank you for saving me hours of pulling my hair out!

    ReplyDelete
  2. @Splash Dog
    You're welcome, glad to see someone else found it useful as well - I know for sure it will happen to me again :-)

    ReplyDelete
  3. awesome -- this was the problem i had as well -- just removing the lib from the MySQL directory fixed it for me

    ReplyDelete
  4. Thank you for this post!! I had the same problem and spent 2 hours trying to figure out what's wrong. Now it finally works.

    ReplyDelete
  5. Hello. I have the same problem but cant figure out how te solve.

    ReplyDelete
  6. I'll take it you have tried checking the PATH and switching the entries as suggested, and that didn't do it for you?

    ReplyDelete
  7. this is an excellent solution.I made sure tht the libmysql.dll file is same in php and mysql

    ReplyDelete
  8. I was facing the same issue. Thanx for the simple and clear solution.

    ReplyDelete
  9. Thanks, glad it helped you, guys.

    ReplyDelete
  10. thanks alot !

    mine is Windows 2008 Standard, Apache 2.2.11

    ReplyDelete
  11. Thanks Ady, good to know.

    I don't know if this is going to be fixed anytime soon, unless they name those linraries differently or PHP checks the library version before use / catches the problem nicely and returns some useful message...

    ReplyDelete
  12. Thank you very much. It's very useful. Spent many hours and your blog resolved in seconds in simple way. Hats off to you!!!

    ReplyDelete
  13. Thanks Thiruppathy, I knew this one must be useful to others (that was actually the 2nd time happening to me).

    ReplyDelete
  14. Simplemente genial!

    Fue de mucha ayuda, gracias!

    ReplyDelete
  15. This was also a real problem for me!

    This topic helped me after troubleshooting for hours.

    ReplyDelete
  16. You're all welcome! glad it helped.

    ReplyDelete
  17. I have had the same error and tried your solution but it didn't worked for me. What finally worked for me is doing the following edit in httpd.conf, comment the line PHPIniDir.... and add two new lines. The result is this:
    #PHPIniDir "C:/Program Files/PHP/"
    AddType Application/x-httpd-php .php
    LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"

    After that change it worked fin for me. I think it is not related with your problem but since I have been googling for a while and didn't find any help I thought it might help someone.

    ReplyDelete
  18. No problem Juan, thanks for contributing.

    ReplyDelete
  19. This has been kicking my arse the last couple of hours. Basically, in Windows if PHP doesn't find the module (dll) that contains libraries that are being referenced in your code it doesn't tell you, it just crashes (which, obviously is dumb).

    In my case it was a new install of PHP and the module that was missing was curl. Uncommented that from php.ini and hey presto.

    ReplyDelete
  20. Fixed for me by adding the php path to my PATH environment variable.

    *php 5.2.11
    *Apache 2.0.50

    ReplyDelete
  21. had the same problem, but my fix was due to apache 2.2.11 not liking 5.3.0 of php. Downgraded to 5.2.11 and worked like a charm.

    ReplyDelete
  22. Same problem with IBM HTTP Server (IHS) V7.0 (and also V6.1), IHS is based on Apache, PHP 5.3.1 and Windows Server2008 x64. But problem was because I installed IHS together with WebSphere Plugins and this installation adds two lines at the bottom of httpd.conf. After I installed PHP and got the problem. Solution is that these two lines must be after two PHP lines at the bottom of httpd.conf:

    #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    PHPIniDir "C:/PHP/"
    AddType application/x-httpd-php .php
    LoadModule php5_module "C:/PHP/php5apache2_2.dll"
    #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL


    LoadModule was_ap22_module "C:\WebSphere\Plugins\bin\32bits\mod_was_ap22_http.dll"
    WebSpherePluginConfig "C:\WebSphere\Plugins\config\webserver1\plugin-cfg.xml"

    ReplyDelete
  23. Same problem with IBM HTTP Server (IHS) V7.0 (and also V6.1), IHS is based on Apache, PHP 5.3.1 and Windows Server2008 x64. But problem was because I installed IHS together with WebSphere Plugins and this installation adds two lines at the bottom of httpd.conf. After I installed PHP and got the problem. Solution is that these two lines must be after two PHP lines at the bottom of httpd.conf:
    #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
    PHPIniDir "C:/PHP/"
    AddType application/x-httpd-php .php
    LoadModule php5_module "C:/PHP/php5apache2_2.dll"
    #END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL


    LoadModule was_ap22_module "C:\WebSphere\Plugins\bin\32bits\mod_was_ap22_http.dll"
    WebSpherePluginConfig "C:\WebSphere\Plugins\config\webserver1\plugin-cfg.xml"

    ReplyDelete
  24. SOLVED.

    Thanks Dan for your kindness in sharing this solution. Like others I spent around 3 hours to fix this and finally got to this post.

    I changed the path, but it didn't work. Then I renamed the "libmySQL.dll" in the bin directory of the MySQL installation, the problem disappeared.

    Thanks for pointing to the right direction and keep up the good work.

    ReplyDelete
  25. Well done. Maybe I should've noted that you need to change the system PATH rather than the user PATH, and restart the service as each process is using a copy of the environment variables at startup. Anyways, good thing you solved it. Process Explorer is also a very good tool, it shows you the PATH that is actually used by a process, simply double click a process and there is a tab for environment variables.

    ReplyDelete
  26. just copy that libmysql.dll from php folder to /bin folder under apache. That worked magic for me and everything else failed...

    ReplyDelete
  27. Like I mentioned earlier, I don't like the copy method, might run into problems when updating PHP or Apache...

    ReplyDelete
  28. i dont't have a libmysql.dll file in my "D:\Program Files (x86)\PHP" and the PHP entry is standing before the mysql.....
    ....still i got errors....

    Name der fehlerhaften Anwendung: httpd.exe, Version: 2.2.14.0, Zeitstempel: 0x4ac181d6
    Name des fehlerhaften Moduls: php5ts.dll, Version: 5.3.1.0, Zeitstempel: 0x4b051b35
    Ausnahmecode: 0xc0000005
    Fehleroffset: 0x000e618c
    ID des fehlerhaften Prozesses: 0x4c0
    Startzeit der fehlerhaften Anwendung: 0x01caa40ce84fa8b6
    Pfad der fehlerhaften Anwendung: D:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe
    Pfad des fehlerhaften Moduls: D:\Program Files (x86)\PHP\php5ts.dll
    Berichtskennung: 27eecbbb-1000-11df-84be-00241dc25a55

    running win7pro x64
    apache 2.2.14, php 5.3.1. and mysqlserver communety edition v5.1.11


    -> i don't know what to do anymore... its confusing

    ReplyDelete
  29. I guess it could crash for a number of reasons, may not be the MySQL DLL - I found that was in my case as I kinda knew what extensions it was using.

    As a good man here suggests at ApacheLounge.com, disable all extensions in php.ini and enable them one by one to see which one crashes.

    http://www.apachelounge.com/viewtopic.php?t=3309

    ReplyDelete
  30. This exact issue just happened to me, and all I did was copy the
    libmysql.dll from php to Apache/bin

    ReplyDelete
  31. Thanks your for the solution, I simply renamed libmysql.dll in the MySQL folder and it worked! will now get back one day earlier home, thanks!!! Rgds from India

    ReplyDelete
  32. @stingray
    Glad it helped, but I wouldn't rename the dll as it might affect other things, of course if it's your system you can remember what you did :-)

    ReplyDelete
  33. Yours was the last fix I tried,
    because it worked. Thank you.

    ReplyDelete
  34. Thanks really a lot! That post saves my day!

    Luca

    ReplyDelete
  35. Hi,

    I am still having the same issue in Win2008 System. We have to use PHP 5.3.2 as some of our modules requires it.

    This is happening, when we open 7-8 browsers to access our web site.
    Windows 2008 R2 64 bit
    1 GB RAM

    Process monitor shows the handle count nearly 2000 when the crash occured.


    Faulting application name: httpd.exe, version: 2.2.15.0, time stamp: 0x4b916754
    Faulting module name: php5ts.dll, version: 5.3.2.0, time stamp: 0x4b8ec7e7
    Exception code: 0xc0000005
    Fault offset: 0x0000bfb7
    Faulting process id: 0x1324
    Faulting application start time: 0x01cc1aff30d82a6b
    Faulting application path: C:AcerSmartClientManagerApache2.2binhttpd.exe
    Faulting module path: C:AcerSmartClientManagerphpphp5ts.dll
    Report Id: e94b8ae8-86f2-11e0-9fa4-001cc055ed38

    Any clues...?

    In windows XP, windows 7 and in other OS i dont find any problem.

    ReplyDelete
  36. @Preethi
    I'm sorry but I'm not an expert in Apache, I merely posted how I used Process Monitor to find a solution for my problem. From what you're saying it works on desktop Windowses, probably 32 bit and it fails on your production environment which is a 2008 R2 64bit.

    Maybe see this as well - http://forums.mysql.com/read.php?11,368345,374825

    ReplyDelete
  37. Thank You very much for your reply.
    We are not using mysql. So that is not the problem i guess. And also it works fine in Windows 7 64-bit.

    only in Windows 2008 64-bit we are facing this issue. Thanks again.

    ReplyDelete