Question

I've added php as a module for Apache 2.2.11:

LoadModule php5_module "c:/php/php5apache2_2.dll"

And also added

AddType application/x-httpd-php .php

And in PHP.ini, my extension dir is set to: extension_dir = "C:\php\ext"

And yes, the directories are correct and all files do exist.

But when I start apache, I get these errors:

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pdo_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0

[Sun May 17 03:46:01 2009] [notice] Apache/2.2.11 (Win32) PHP/5.2.9-2 configured -- resuming normal operations
[Sun May 17 03:46:01 2009] [notice] Server built: Dec 10 2008 00:10:06
[Sun May 17 03:46:01 2009] [notice] Parent: Created child process 4652

PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pdo_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_pgsql.dll' - The specified module could not be found.\r\n in Unknown on line 0

[Sun May 17 03:46:01 2009] [notice] Child 4652: Child process is running
[Sun May 17 03:46:01 2009] [notice] Child 4652: Acquired the start mutex.
[Sun May 17 03:46:01 2009] [notice] Child 4652: Starting 64 worker threads.
[Sun May 17 03:46:01 2009] [notice] Child 4652: Starting thread to listen on port 80.

So I'm probably forgetting something simple here, can someone tell me what I'm forgetting?

Was it helpful?

Solution

Not only you need PHP extension's DLLs in order to add MySQL and PostgreSQL support to PHP. You also need MySQL and PostgreSQL native libraries. PHP extension's DLLs are probably not finding some DLL they depend on, so they can't start.

Make sure you have MySQL and PostgreSQL client installed, and their DLLs into some locatable place.

I.E. example:

  • php_mysql.dll depends on libmysql.dll

So, make sure PHP is able to find libmysql.dll (I believe this one comes with the binary distribution of Windows PHP. Not sure though).

OTHER TIPS

To add to Pablo Santa Cruz's advice. On windows you can include the required libraries in the PATH environment. (No necessarily copy to Windows folder). When loading libraries widows looks in PATH directories as well.

If you use standard Win32 binary distribution from php.net for PHP5.2, then the package should contain all the dependencies in the root of the packages. So, if you have installed the PHP5.2 into C:\php, add this directory to the PATH envar. Restart the Apache and I'd expect extensions to load properly.

I had a problem with a specific version of PHP on Windows. The problem was libmysql. I found a posted bug on the php.net site from someone having the same problem.

I used the previous php release and libmysql worked. Check out the notes on the php distribution you are using. I think that after a specific version they mention a new policy regarding libmysql.

From what you mention php is unable to find the extensions. Make sure you have set the path on php.ini that specifies where the extensions are located, that the extensions exist and that the folder can be accessed (read-permissions).

If all fails try moving the extension to windows/system32 in an effort to find what might be the real problem.

Regards,

Those extensions depend on native libraries which are provided by the MySQL and PostgreSQL binary distributions. Install them and put the libs in apache's bin folder for example. Those are LIBMYSQL.DLL and LIBPQ.DLL respectively.

I usually do that instead of polluting Windows/System32 folder with them, because on my system only the apache/php is the client of those databases and also it makes my apache/php setup more portable.

In my experience, PHP on Windows is a major pain in the behind. I usually get it to work eventually, but there's always a lot of googling and trial-and-error involved - for me at least.

So I finally got sick and tired of it and simply installed Ubuntu Server in a VM and had it up and running within minutes. Whether this is an option for you or not I can't say, but if it is it will most definitely save you a lot of headaches in the long run. Not to mention you can always move your VMs around, create snapshots and do all the other fancy stuff that VMs are good for.

I had the same problem. I was getting one of those annoying windows popup errors everytime I tried to log in to phpmyadmin. I typed in the username and password and then would throw the error.

What solved it for me, was also copying the libmysql.dl to the apache bin directory. The strange thing is apparantly the extensions where included correctly but still I needed to do this.

I tried several of these solutions and one or more of them worked... Rebooting is the key here. I did not reboot in between these changes, but after I rebooted it was working:

  • add postgres DLL to apache lib dir
  • add postgres path to system PATH
  • add postgres DLL to system32

I believe just the PATH would have worked but no time for cleanliness here so there you go.

the problem here is that apache has loaded PHP, but PHP was not able to load its extension (mysql, postgresql, ...). I think you should enter path values in your php.ini file in unix format (do not use backslash characters as directory separator). so in your php.ini file change this:

extension_dir="C:/php/ext"

I'm also had same problem and solved by adding "PostgreSQL" bin path into System Environment variables

PATH: C:\Program Files\PostgreSQL\8.4\bin You can check in phpinfo() also.

When I install PostgreSQL, setting into System Path missed. I manually added then restart the system.

I had this problem too, and copied the pertinent (.dlls) to systen 32 and it still did not work for me. I am running Windows 7 64bit. To get this to work for me I had to also copy the libmysql.dll to the ext directory. The error message left the Apache log and the page loaded with a favorable response (conection established).

I had the same problem and have tried copying libmySQL.dll to the apache bin folder and it solved the problem (I'm setting up PHP 5.2.5 x64). Many thanks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top