MySQL, PHP, Apache, Drupal and Win7 gotcha

It took over an hour to figure this one out this morning. Setting up Drupal 6 on Windows 7 (instead of Linux, which would be my preferred platform but this time I’d no choice). Everything went smoothly until I got the White Screen Of Death (blank page) when I tried to launch the install.php. OK, probably screwed up the MySQL URL in settings.php. Nope. That’s the usual usr:pwd@localhost/db format, too simple to get wrong. Apache errors? Nope, nothing in the logs. Apache .htaccess or <Directory> options? Nope, I’m using familiar and well-tested boilerplate. And on it went down the diagnostics rat-hole.

Eventually I checked the MySQL session connections and there was no sign of anything inbound. Uh oh… Double check the connection URL. Still fine. Perhaps MySQL access permissions? Added usr@% and usr@localhost users with appropriate rights, but still nothing. Is my installation URL correct? Even checked DNS. All fine. Something blocking localhost traffic?

This is where I did “ping localhost” and got back the following:

pinging MyLaptop [::1] with 32 bytes of data:
Reply from ::1: time<1ms

What the…? That’s an IPv6 localhost, not IPv4 (which would be 127.0.0.1). Quickly edited the Drupal settings.php to use usr:pwd@127.0.0.1/db instead and voila! No more WSOD! So it would seem that PHP 5.3 is getting an IPv6 resolution to localhost when parsing the connection URL and then fails to connect to MySQL (which doesn’t support IPv6).

I presume this also affects Vista and Windows Server 2008. Not sure if it would also affect IPv6 enabled Un*x platforms but I’ll keep it in mind.

Categorised as: Uncategorized

Comment Free Zone

Comments are closed.