PHP 5.3.1 upgrade on IIS7 and MySQL gives Internal Server Error

Solution

After a lot of googling and testing I finally found Bruce Kirkpatrick’s comment at the end of the PHP install manual

Seems it is no longer enough to have localhost in the servers local hosts file (C:\Windows\System32\drivers\etc\hosts) you also have to comment out or remove the IPv6 equivalent.

127.0.0.1 localhost
#::1 localhost

After I did this everything worked ok again. Thanks Bruce!

Problem

I just upgraded PHP on my Windows Server 2008 running IIS7 from PHP 5.2.10 to 5.3.1. Used the non-threaded install package and installed for FastCGI.

After the upgrade installation worked fine for some non-database driven pages and phpinfo worked fine but whenever a page tries to accessed the MySQL database the browser only gave me a 500 Internal Server Error.

Checking the php error log (C:\Windows\Temp\php-errors.log) I get messages like this:

[24-Feb-2010 13:44:36] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\inetpub\wwwroot\XXX\init_page.inc on line 32
[24-Feb-2010 13:44:36] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
in C:\inetpub\wwwroot\XXX\init_page.inc on line 32
[24-Feb-2010 13:44:36] PHP Fatal error: Maximum execution time of 60 seconds exceeded in C:\inetpub\wwwroot\XXX\init_page.inc on line 32

3 comments

Leave a Reply to Brenda Cancel reply

Your email address will not be published. Required fields are marked *