PHP 5.1.2, MySQL 5.0.18 and IIS woes

Installing PHP 5.1.2 and MySQL 5.0.18 on Windows Server 2003 was a complete nightmare. Although each one installed without any problems, for some odd reason, PHP refused to load the MySQL module, making it practically useless. There were no errors, nothing. No indication to show what was wrong. It appears that the problem was caused by quote marks around the extension_dir value in php.ini, which for some odd reason cause modules not to be loaded in the latest version of PHP (5.1.2) although it’s never been an issue in previous releases.

Rather annoyingly, there’s also two versions of the MySQL libraries floating around. The PHP installer has one version, and there’s a newer version on the MySQL website which they recommend downloading and using.

Steps I took to get things working:

Things to download:

PHP 5.1.2 installer
PHP 5.1.2 zip package
MySQL 5.0.10 Windows Installer
MySQL 5.0.18 connectors (both MySQL and MySQLi).

First install MySQL 5.0 by running the installer. Once completed, go through the server configuration wizard to configure things. Nothing complicated here.

Next, install PHP by running the installer. You should install to C:\PHP (to keep things easy). Press yes when prompted to set-up IIS with the correct script mappings. Once that’s done, unzip the PHP zip package over C:\PHP. This is because the Windows installer doesn’t include any of the additional modules (but the zip file does).

After that, unzip the MySQL connectors. Copy the php_mysql.dll and php_mysqli.dll files to C:\PHP\ext and the lib*.dll files to C:\PHP.

Edit C:\Windows\PHP.ini. Look for the line starting with extension_dir and make sure that the line reads extension_dir = C:\PHP\ext – without quotes. Scroll down and remove the semicolon from the start of the line extension=php_mysql.dll and also from extension=php_mysqli.dll.

Now restart IIS. A quick way to do this is typing iisreset from the command prompt.

If you didn’t set up the script mappings in IIS as part of the PHP installation, you will need to do these manually. The PHP extension must be mapped to php5isapi.dll. If using Windows 2003 Server, make sure you also set up PHP in IIS Web Service Extensions and set its status to allowed.

Once everything is done, check that PHP and MySQL are working by creating a PHP file which calls phpinfo() and accessing this file through your web browser. You should have the mysql and mysqli settings listed between the libxml and odbc settings.

Hope this helps someone out there! :-)

Updated on 07 February 2006, recommending use of php5isapi.dll instead of php-cgi.exe, as this is designed for IIS and offers better performance..

This entry was posted in Uncategorized by Mun. Bookmark the permalink.

Leave a Reply

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

*