Installation of extensions on Windows

After installing PHP and a web server on Windows, you will probably want to
install some extensions for added functionality. You can choose which
extensions you would like to load when PHP starts by modifying your
php.ini. You can also load a module dynamically in your script using
dl().

The DLLs for PHP extensions are prefixed with php_.

Many extensions are built into the Windows version
of PHP. This means additional DLL files, and the
extension directive, are
not used to load these extensions. The Windows
PHP Extensions
table lists extensions that require, or used to require, additional PHP
DLL files. Here's a list of built in extensions:

// change the following line from ...
;extension=php_bz2.dll
// ... to
extension=php_bz2.dll

Some of the extensions need extra DLLs to work. Couple of them can be
found in the distribution package, in the
C:\php\dlls\ folder in PHP 4 or
in the main folder in PHP 5, but some, for example Oracle
(php_oci8.dll) require DLLs which are not bundled
with the distribution package. If you are installing PHP 4, copy the
bundled DLLs from C:\php\dlls
folder to the main C:\php
folder. Don't forget to include C:\php in the system
PATH (this process is explained in a separate FAQ entry).

Some of these DLLs are not bundled with the PHP distribution. See each
extensions documentation page for details. Also, read the manual
section titled Installation of PECL
extensions for details on PECL. An
increasingly large number of PHP extensions are found in
PECL, and these extensions require a
separate download.

Informacja:
If you are running a server module version of PHP
remember to restart your web server to reflect your changes to php.ini.

The following table describes some of the extensions available and required
additional dlls.

User Contributed Notes 15 notes

On Windows hosts libeay32.dll and ssleay32.dll have to be path-accessible for php_curl.dll to work correctly. Copying them into System32 (or even into the Windows main directory) is a bad hack (and does not even work with newer PHP versions). The right way to do it, is to add the PHP path to the Windows *Path* variable. In *Control Panel* --> *System* click on *Advanced System Settings* and use the button *Environment Variables*. Under *System Variables* you will find the *Path* variable. Edit it and append `;C:/PHP` to it - or whatever the path to your PHP root folder is.

4. Set your PATH for Windows to find php (if you haven't already):a. Right-click on My Computerb. Propertiesc. Advanced Tab > Environment Variablesd. Under System variables, scroll down to find "Path", select and click on Edite. Add path to your php install on the end (make sure to precede with semi-colon ";"). Mine was ";G:\Apache\php"f. Click Okay. (then "Okay" on each of the other open windows).

5. Test php install. (see ricocheting link above for testing).

6. Getting the extensions to work again:a. Open php.inib. uncomment each extension, restart Apache.

7. Special note on libmysql.dll and problems getting MySQL to work:- You may have copied over this file into your Windows/System32 (or WINNT/System32 for me) to get mysql to work in the past. If so, replace it with the most recent version you get with the upgrade (in top dir).- If this is a fresh install, copy the libmysql.dll into your System32 folder.

Couple notes:1. The above tutorial link is to install php 5.x on Apache 2.2 for Win. If you're running Apache 2.0 like me, pay special attention to "Editing Apache Conf File" for correct LoadModule info.2. If you ran the installer previously, double check your Apache conf where the php5 LoadModule stuff is. The installer might have messed with this a bit.

...didn't export the $PATH change such that restarting the Apache service (in MMC) would pick it up. So I tested the working solution (adding PHP dir to $PATH), but it failed because of HOW I set it. It succeeded only when I REBOOTED after changing the $PATH. There may be an easier way that this, but I do not know it at present.

== Comment

Consider whether PHP dir should need to be in $PATH at all, when PHP.exe apparently was found and executes php pages in Apache, but php5apache2_2.dll failed to find whatever was needed to load the extensions. This should perhaps be addressed.

Note that on a WAMP installation (W2K,Apache,MySQL,PHP), only PHP is required in $PATH.

Installing PHP extensions for IIS for the first time is sort of a baptism by fire -- you will get your hands dirty, and other suitable metaphors of nastiness. Hopefully, you won't have to spend too many days googling around fora and restarting IIS 10 million times as I did until I finally realized both what was going on and what crazy things I'd done wrong.

THIS (peter)guy really goes into terrific detail and troubleshooting, (with very good reasons and explanations of extension dependencies not listed on the current php page you're now reading):

The main problem I'd been butting my head up against was extensions being reported as not found, even though the .DLLs were definitely in C:\PHP\ext, and my PATH env var was setup correctly.

The error messaging during dynamic loading of implicitly-linked libraries should be more specific, telling you that in fact it is a particular dependency of a dependency which is missing -- usually some obscure third-party .dll -- and name it!

Eventually I stopped being so greedy and just cut down on the extensions I thought I needed by commenting them out in php.ini. That eliminated the startup errors. Apparently some of these extensions or their requirements, which either come with the base PHP install zip or the PECL extensions, are either too obscure or too fragile to be necessary anyway.

Good luck, and I hope anyone who runs into the same trouble can hit upon this or Peter Guy's page directly before they go too crazy.

After much searching I discovered the reason why my dll was not found was simply because an old version of easy-php had left an entry in the path variable which was being used instead of the entry I added at the end.

I had a problem with the gd and mysqli mods on my PHP5.2/Apache2.2/Windows 2003 server. Even after enabling the options in the php.ini file and restarting the Apache service, the mods still would not load. I even tried to restart the Windows 2003 server that php is loaded on - and no go. After reviewing the system path variables in Windows, I noticed that the c:\php directory was set in the path variable, but not the folder for the gd, mysqli and others mods. So I added c:\php\ext to the path variable and rebooted the server. THAT FIXED IT!!

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

When PHP definitely should be able to find the module, it's fairly common knowledge that this error can also be caused by certain dlls not being in the PATH. These dlls (usually libeay32 and ssleay32) are generally found in your base php directory, and the modern windows installers add the base php directory to the PATH so that you don't need to worry about it. However, if when installing earlier versions you decided on moving libeay32, ssleay32 et al to C:\Windows\System32 instead of changing the PATH, then php will still end up with the old versions and the out of date versions will cause the same error as above. Don't fall into the trap like I did.

By using sysinternals procmon I saw that it failed after trying to load "zlib.dll". I found this file deployed with other software (in my case, Miranda IM) and copied it to the PHP installation directory. It worked fine after that. Hope that helps.