Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP extensions won't load on Apache startup

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?

like image 380
KdgDev Avatar asked May 17 '09 02:05

KdgDev


People also ask

How do I enable PHP extensions in Windows?

On Windows, you have two ways to load a PHP extension: either compile it into PHP, or load the DLL. Loading a pre-compiled extension is the easiest and preferred way. To load an extension, you need to have it available as a ". dll" file on your system.

Does apache2 have PHP?

The PHP module for Apache is not bundled with Apache. As such, it must be installed in addition to the Apache package. Once installed the module will have to be enabled.


2 Answers

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).

like image 84
Pablo Santa Cruz Avatar answered Oct 01 '22 17:10

Pablo Santa Cruz


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.

like image 31
Max Kosyakov Avatar answered Oct 01 '22 17:10

Max Kosyakov