cliveb Posted April 18, 2017 Share Posted April 18, 2017 Hi - new member here with a seemingly bizarre problem with PHP extensions and Apache2 running under Windows 7 Pro.Apache2 is working fine for simple PHP scripts. But when I want to use any extensions (MySQL in this case), Apache2 fails to load the DLL. PHP from the command line works just fine using the extension.In the Apache2 error log I see this on startup:PHP Warning: PHP Startup: Unable to load dynamic library './php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0So I thought "Aha! Apache must be running in a different directory - easy fix"I edited PHP.INI and changed extension_dir to C:/php/ext/; now I see this in the Apache2 log:PHP Warning: PHP Startup: Unable to load dynamic library 'c:/php/ext/php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0So then I wondered if perhaps command line PHP was using a different PHP.INI. To test this, I deliberately edited the mysqli extension in PHP.INI with an invalid name, and PHP from the command line (as expected) said this:PHP Warning: PHP Startup: Unable to load dynamic library 'c:/php/ext/php_mysqli_xxx.dll' - The specified module could not be found. in Unknown on line 0And the Apache2 error log says:PHP Warning: PHP Startup: Unable to load dynamic library 'c:/php/ext/php_mysqli_xxx.dll' - The specified module could not be found.\r\n in Unknown on line 0Which proves that they are using the same PHP.INI. I also tried using backslashes instead of forward slashes in PHP.INI just in case Windows wanted them, but got this: PHP Warning: PHP Startup: Unable to load dynamic library 'c:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0 The last thing that occured to me was perhaps permissions were wrong, as Apache2 runs under the SYSTEM account. But I checked and SYSTEM has full permissions to the DLL and all folders leading to it.So I'm baffled. Can anyone suggest anything else to try? Quote Link to comment https://forums.phpfreaks.com/topic/303734-apache-and-php-extensions-problem/ Share on other sites More sharing options...
requinix Posted April 18, 2017 Share Posted April 18, 2017 The "module could not be found" error can also mean that a dependency of the DLL cannot be loaded. The only ones in php_mysqli.dll should be basic PHP stuff and other system files you already have - unless you're running an old PHP (at least What PHP do you have and where did you download it? Quote Link to comment https://forums.phpfreaks.com/topic/303734-apache-and-php-extensions-problem/#findComment-1545604 Share on other sites More sharing options...
cliveb Posted April 19, 2017 Author Share Posted April 19, 2017 Thanks for the reply. I hadn't realised it could be other dependencies. I tried activating some other random extensions to check (such as dbase, mssql, bz2 and the like) and there were no errors about them in the Apache log. I am running an old PHP (5.2.9), along with an old Apache (2.0.54). I just had the install files lying around from way back (when it had all worked fine on Windows XP). I'll get the latest Apache2 and PHP and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/303734-apache-and-php-extensions-problem/#findComment-1545617 Share on other sites More sharing options...
requinix Posted April 19, 2017 Share Posted April 19, 2017 Holy crap, 5.2? Yeah. Upgrade. PHP 7.0 and Apache 2.2 at the earliest. Anyway, mysql and mysqli back then used libmysql - the former was the PHP API as an optional DLL like normal, the latter was the actual driver itself and had its own DLL. Since libmysql.dll and php_mysqli.dll are in different places, and neither are generally visible to the Apache process (technically, visible to Windows when it searches for DLLs that are being loaded by Apache), that fails. The most common solution to this was to copy libmysql.dll into Windows\System32 where Windows would have no problem finding it, however that's actually a bad practice. Quote Link to comment https://forums.phpfreaks.com/topic/303734-apache-and-php-extensions-problem/#findComment-1545618 Share on other sites More sharing options...
cliveb Posted April 20, 2017 Author Share Posted April 20, 2017 I was aware of the libmysql.dll issue and had put a copy into Windows\system32, so that wasn't the issue. Anyhow, I've upgraded to PHP 7.0 and Apache 2.4 and all is now working fine. Many thanks for your help - much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/303734-apache-and-php-extensions-problem/#findComment-1545655 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.