SunshinePHP Developer Conference 2015

Instalação de extensões no Windows

Depois de instalar o PHP e um servidor web no Windows, você provavelmente desejará instalar algumas extensões para ter funcionalidades extras. Você pode escolher quais extensões você quer que o PHP carregue quando é iniciado modificando o arquivo php.ini. Você também pode carregar um módulo dinamicamente no seu script usando dl().

Os DLLs para extensões do PHP são prefixadas com php_.

Muitas extensões são compiladas dentro da versão para Windows. Isso significa que arquivos DLL adicionais, e a diretiva extension, não são utilizadas para carregar essas extensões. A tabela de Extensões PHP lista extensões que requerem, ou costumavam requerer, arquivos DLL adicionais do PHP. Aqui está uma lista das extensões já compiladas dentro do PHP:

No PHP 4 (atualizado PHP 4.3.11): BCMath, Caledar, COM, Ctype, FTP, MySQL, ODBC, Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib

No PHP 5 (atualizado PHP 5.0.4), as seguintes mudanças existem. Embutido: DOM, LibXML, Iconv, SimpleXML, SPL and SQLite. E os seguintes não são mais embutidos: MySQL e Overload.

A localização padrão que o PHP procura por extensões é C:\php4\extensions no PHP 4 e C:\php5 no PHP 5. Para mudar esta configuração para refletir sua instalação do PHP, edite o arquivo php.ini:

  • Você precisará mudar a configuração extension_dirpara apontar o diretório onde suas extensões estão guardadas, ou onde você colocou os arquivos php_*.dll. Por exemplo:

    extension_dir = C:\php\extensions

  • Habilite a(s) extensão(ões) no arquivo php.ini que você quiser descomentando as linhas extension=php_*.dll. Isso é feito removendo o ; na antes da linha com a extensão que você quer carregar.

    Exemplo #1 Habilitar a extensão Bzip2 para o PHP-Windows

    // Mude a seguinte linha de ...
    ;extension=php_bz2.dll
    
    // ... para
    extension=php_bz2.dll

  • Algumas das extensões precisam de DLLs extras para funcionarem. Algumas delas podem ser encontradas no pacote da distribuição, na pasta C:\php\dlls\ no PHP 4 ou na pasta principal no PHP 5, mas algumas, por exemplo o Oracle (php_oci8.dll) requerem DLLs que não estão agregadas ao pacote da distribuição. Se você estiver instalando o PHP 4, copie as DLLs agregadas da pasta C:\php\dlls para a pasta principal C:\php. Não se esqueça de incluir C:\php na variável de ambiente PATH (esse processo é explicado em outra página, nesse FAQ).

  • Algumas destas dlls não sao embutidas com a distribuição do PHP. Veja a documentação de cada extensão para maiores detalhes. Também leia o manual na sessão entitulada Instalação de extensões PECL para detalhes sobre PECL. Um crestente número de extensões para o PHP são encontradas no PECL, e estas extensões precisam de um download separado.

Nota: Se você estiver executando a versão de módulo do servidor do PHP lembre de reiniciar o servidor web para que as mudanças no arquivo php.ini sejam efetivadas.

A tabela a seguir descreve algumas das extensões disponíveis e as dlls adicionais requeridas.

Extensões do PHP
Extensão Descrição Notas
php_bz2.dll Funções de Compressão de bzip2 Nenhuma
php_calendar.dll Funções de Conversão de Calendar Integrado desde o PHP 4.0.3
php_crack.dll Funções de Crack Nenhuma
php_ctype.dll Família de Funções ctype Integrado desde o PHP 4.3.0
php_curl.dll Biblioteca de Funções de Cliente URL - CURL Requer: libeay32.dll, ssleay32.dll (agregado)
php_dba.dll Camada de Funções de Abstração de Banco de Dados DBA Nenhuma
php_dbase.dll Funções de dBase Nenhuma
php_dbx.dll Funções dbx  
php_domxml.dll Funções DOM XML PHP <= 4.2.0 requer: libxml2.dll (agregado) PHP >= 4.3.0 requer: iconv.dll (agregado)
php_dotnet.dll Funções .NET PHP <= 4.1.1
php_exif.dll Funções EXIF php_mbstring.dll. e, php_exif.dll devem ser carregados depois de php_mbstring.dll no arquivo php.ini.
php_fbsql.dll Funções FrontBase PHP <= 4.2.0
php_fdf.dll Funções de Formato de Dados de Formulários (Forms Data Format) FDF. Requer: fdftk.dll (agregado)
php_filepro.dll Funções de filePro Acesso apenas de Leitura
php_ftp.dll Funções de FTP Integrado desde o PHP 4.0.3
php_gd.dll Funções da biblioteca de imagens GD Removido no PHP 4.3.2. Note também que funções truecolor functions não estão disponíveis no GD1, ao invés, use php_gd2.dll.
php_gd2.dll Funções da biblioteca de imagens GD GD2
php_gettext.dll Funções de Gettext PHP <= 4.2.0 requer gnu_gettext.dll (agregado), PHP >= 4.2.3 requer libintl-1.dll, iconv.dll (agregado).
php_hyperwave.dll Funções de HyperWave Nenhuma
php_iconv.dll Conversão de tabela de caracteres ICONV Requer: iconv-1.3.dll (agregado), PHP >=4.2.1 iconv.dll
php_ifx.dll Funções de Informix Requer: Informix libraries
php_iisfunc.dll Funções de manuseio de IIS Nenhuma
php_imap.dll Funções de IMAP POP3 e NNTP Nenhuma
php_ingres.dll Funções de Ingres II Requer: Ingres II libraries
php_interbase.dll Funções de InterBase Requer: gds32.dll (agregado)
php_java.dll Funções de Java PHP <= 4.0.6 requer: jvm.dll (agregado)
php_ldap.dll Funções de LDAP PHP <= 4.2.0 requer libsasl.dll (agregado), PHP >= 4.3.0 requer libeay32.dll, ssleay32.dll (agregado)
php_mbstring.dll Funções de Multi-Byte String Nenhuma
php_mcrypt.dll Funções de Mcrypt Encryption Requer: libmcrypt.dll
php_mhash.dll Funções de Mhash PHP >= 4.3.0 requer: libmhash.dll (agregado)
php_mime_magic.dll Funções de Mimetype Requer: magic.mime (agregado)
php_ming.dll Funções de Ming para Flash Nenhuma
php_msql.dll Funções de mSQL Requer: msql.dll (agregado)
php_mssql.dll Funções de MSSQL Requer: ntwdblib.dll (agregado)
php_mysql.dll Funções de MySQL PHP >= 5.0.0, requer libmysql.dll (agregado)
php_mysqli.dll Funções de MySQLi PHP >= 5.0.0, requer libmysql.dll (libmysqli.dll in PHP <= 5.0.2) (agregado)
php_oci8.dll Funções de Oracle 8 Requer: Oracle 8.1+ client libraries
php_openssl.dll Funções de OpenSSL Requer: libeay32.dll (agregado)
php_overload.dll Funções de Overload Integrado desde o PHP 4.3.0 >= 5.0.0
php_pdf.dll Funções de PDF Nenhuma
php_pgsql.dll Funções de PostgreSQL Nenhuma
php_printer.dll Funções de Impressora Nenhuma
php_shmop.dll Funções de Memória Compartilhada Nenhuma
php_snmp.dll Funções de get and walk de SNMP Apenas no NT!
php_soap.dll Funções de SOAP PHP >= 5.0.0
php_sockets.dll Funções de Socket Nenhuma
php_sybase_ct.dll Funções de Sybase Requer: bibliotecas de cliente do Sybase
php_tidy.dll Funções de Tidy PHP >= 5.0.0
php_tokenizer.dll Funções de Tokenizer Integrado desde o PHP 4.3.0
php_w32api.dll Funções de W32api Nenhuma
php_xmlrpc.dll Funções de XML-RPC PHP >= 4.2.1 requer: iconv.dll (agregado)
php_xslt.dll Funções de XSLT PHP <= 4.2.0 requer sablot.dll, expat.dll (agregado). PHP >= 4.2.1 requer sablot.dll, expat.dll, iconv.dll (agregado).
php_yaz.dll Funções do YAZ Requer: yaz.dll (agregado)
php_zip.dll Funções para Arquivos Zip Acesso apenas de leitura
php_zlib.dll Funções de compressão de ZLib Integrado desde o PHP 4.3.0

add a note add a note

User Contributed Notes 12 notes

up
3
JB
5 years ago
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!!
up
3
smaines at alaya dot com
6 years ago
== Problem

Consider the following from an httpd.conf file...

  LoadModule php5_module "E:/xyz/php/php5apache2_2.dll"
  PHPIniDir "E:/xyz/php"

...which led to the dreaded...

  PHP Warning:  PHP Startup: Unable to load dynamic library 'E:\\xyz\\php\\ext\\php_mysql.dll' - The specified module could not be found.

Note, however, that PHP.exe apparently was found and executed php pages in Apache, but the MySQL functions therein failed.

== Solution

Because PHP dir was not in $PATH, php5apache2_2.dll failed to find php_mysql.dll (the only extension I enabled) during Apache 2.2 start.

== Caveat (!)

The BIG issue is that, setting $PATH in...

  <desk icon>My Computer
  <rt click>Properties
  <tab>Advanced
  <button>Environment Variables

...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.
up
2
simi_def at c2 dot hu
8 years ago
I had problems with PHP5/Apache2.2/MySQL 5 installation on a WinXp machine.

I got the

Fatal error: call to undefined function - mysql_connect().

message

Solution :
1, use correct version of ext\php_mysql.dll and libmysql.dll
2, !!! edit the CORRECT php.ini (%windir%\php.ini) like c:\windows\php.ini !!!
3, add php installation dir to PATH
4, edit php.ini to load extension php_mysql.dll

use
<?php
phpinfo
();
?>
to check.
up
1
amainATgoldcoastdesignORG
6 years ago
I just recently tried to upgrade my php install on WinXP using the php-5.2.6-win32-installer.msi and with fingers crossed, tried to see if things still worked or not.

Unfortunately, they didn't.  I did see many posts here and elsewhere on the web regarding the error message:

"Unable to load dynamic link library 'ext\php_xxxxx.dll' - The specified module could not be found."

php.net says in the past when upgrading to simply copy over new php files, but now recommends using the windows installer.  Maybe the installer isn't quite up to the task yet.

My fix:

1. Completely uninstall current version of php (using Windows Control Panel > Add or Remove Programs).

2. Download the current php binaries for Windows (at php.net/downloads.php under Windows Binaries).  Should be format: PHP 5.x.x zip package.  Again, download the binaries, NOT the installer.

3. Follow these easy steps
http://www.ricocheting.com/server/php.html

4. Set your PATH for Windows to find php (if you haven't already):
a. Right-click on My Computer
b. Properties
c. Advanced Tab > Environment Variables
d. Under System variables, scroll down to find "Path", select and click on Edit
e. 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.ini
b. 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.

I hope this stuff helps.
-Art
up
1
JerryG
7 years ago
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):

http://www.peterguy.com/php/install_IIS6.html

Most of this is applicable for IIS5.1 as well, as far as I've found.

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.
up
1
Anonymous
4 years ago
I had problem with extensions - they don't loaded (without errors) on Windows installation and don't displayed in phpinfo().

Solve: full-specified directory name for extension_dir directive - "c:/php/ext/" instead "./"
up
1
mech
8 months ago
If you have problems, that windows-extensions can not be loaded (PHP Warning: PHP Startup: Unable to load dynamic library) and you are sure, the .ddl is in the right place, use ProcessMonitor (http://technet.microsoft.com/de-de/sysinternals/bb896645.aspx)

here you can see at startup, which files php tries to find and in which locations php tries to find them!
up
0
jwagner at digilog dot de
7 days ago
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.
up
0
jma59 at cam dot ac dot uk
7 years ago
Under windows, given an error similar to

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.
up
-1
Manda Krishna Srikanth
6 years ago
As far as my experience says, 95% of ext\php_mysql.dll - The specified module could not be found - error can be sorted out on Win 2003, IIS 6, PHP5.2.

Replace the php_mysql.dll and libmysql.dll downloaded from http://dev.mysql.com/downloads/connector/php/ into extensions directory.

For MSSQL connectivity problems, replace the ntwdblib.dll in php dir with the one copied from system32 directory. Ofcourse the filesize will be less, no problem, replace it.
up
-1
vatozana at yahoo dot com
4 years ago
I had problems registering Curl extentions and it was cause by the old dll of libeay32.dll and  ssleay32.dll  which were already in my c:\windows\system32 I replaced them and all is now fine!!
up
-2
rafaurl at gmail dot com
3 years ago
I got the following error:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\PHP\ext\php_curl.dll'

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.
To Top