php5与apache工作没有问题，但是和iis整合不到一起，访问数据库时会报错：Fatal error: Call to undefined function mysql_connect() in
Configuration File (php.ini) Path C:/WINDOWS
Loaded Configuration File (none)
It seems every time I try to install PHP and MySQL something doesn't work - usually there's either a file missing from the PHP distro or something in the install notes is missing or incorrect. This time it was both.
I first tried the PHP msi install - first mistake. As it does not include the MySQL extensions - neither does the 5.2.6 PECL zip file (I mistakenly thought this would include all the extensions). So if you've installed PHP using the MSI installer - uninstall it (via Control Panel - Add/Remove Programs). Also - you may need to manually remove any remants of this PHP installation manually - I had to manually delete the php directory.
Now with a clean slate do the following:
1. Download the PHP zip package from here.
2. Extract the zip - in my case into C:/PHP5
3. Copy php.ini-recommended and rename it to php.ini (within this same dir).
4. Edit php.ini and make the following changes:
1. Set the extension dir eg:
extension_dir = "C:/PHP5/ext"
2. Uncomment the extension setting for mysql eg remove the ';' from the beginning of the line:
5. Within IIS admin tool:
1. Within Application Configuration (within 'Home Directory' of a site) add the php extension - mapping 'php' to php5isapi.dll (eg D:/php-5.2.6-Win32/php5isapi.dll).
2. Within Web Service Extensions add one for php5isapi.dll (eg D:/php-5.2.6-Win32/php5isapi.dll) setting it to 'Allowed'.
6. Update the PATH environment variable to include the php dir eg D:/php-5.2.6-Win32.
7. Add a new environment variable called PHPRC and set to the php dir eg D:/php-5.2.6-Win32 (this part was missing from the install docs for IIS).
8. Restart iis (eg run iisreset from the command prompt).
Bingo - that's it. To test create a file called phpinfo.php (and place in the web root) with the following:
The critical part to check here is that the output of this phpinfo shows the 'Loaded Configuration File' is set to the php.ini file you created above. If PHP is configured correctly to use mysql it this (phpinfo output) will have a MySQL section - if this is missing - then something is wrong.