SYMPTOMS AND SETUP
------------------
For anyone having problems enabling the PHP openssl extension on WINDOWS.
I uncommented: extension=php_openssl.dll and installed the latest versions of ssleay.dll and libeay.dll in <windows>\system32.
When I restarted my web server and examined phpinfo(), there was no "openssl" headed section (although there were references to openssl in other sections).
I also found this error in my web server logs (<apache dir>/logs/ssl.log and <apache dir>/logs/access.log).
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\ext\\php_openssl.dll' - The operating system cannot run %1.\r\n in Unknown on line 0
I have PHP 5.2.6 running on Apache 2.2.3 for Windows.
CAUSE
-----
This was caused by PHP picking up the WRONG VERSIONS of libeay.dll and ssleay.dll, which were present in multiple locations on my computer.
When any application attempts to use a dll file in windows, the system searches for this file using the following order:
1. The directory from which the application loaded.
2. The windows\system32 directory.
3. The windows\system directory.
4. The windows directory.
5. The current directory.
6. The directories that are listed in the PATH environment variable.
(http://msdn.microsoft.com/en-us/library/ms682586.aspx)
For PHP running under Apache, the application directory is <apache dir>\bin and NOT <php dir>. PHP was finding OUT OF DATE versions of libeay.dll and ssleay.dll in <apache dir>\bin (probably installed when I enabled SSL support in my web server). Because of this, the latest versions in windows\system32 were never reached.
NOTE: Although my problem was caused by an Apache2 specific configuration, I can imagine others might face this problem if, say, they install the openssl dlls in the PHP directory and add this directory to the PATH. I haven't checked it but I would imagine if another directory in the path contains outdated openssl dlls and this is listed before the PHP directory, a similar situation would occur.
SOLUTION
--------
Either replace the dlls in the first location on the search order, or, as I did, you can install the latest openssl dlls in the the windows system32 directory and just rename to .old the ssleay.dll and libeay.dll files in the search order locations before windows\system32.
Hope that helps others who might be stuck with this.
Mark.
Installation
Pour utiliser le support OpenSSL de PHP, vous devez aussi compiler PHP avec l'option de configuration --with-openssl[=DIR].
Note: Note aux utilisateurs Win32
Afin de faire fonctionner cette extension, quelques bibliothèques DLL doivent être disponibles via le PATH du système Windows. Lisez la FAQ intitulée "Comment ajouter mon dossier PHP à mon PATH WIndows" pour plus d'informations. Le fait de copier les bibliothèques DLL depuis le dossier PHP dans le dossier système Windows fonctionne également (car le dossier système est par défaut dans le PATH système), mais cette méthode n'est pas recommandée. Cette extension nécessite que les fichiers suivants se trouvent dans le PATH : libeay32.dll
De plus, si vous envisagez de générer des clés et de signer des messages, vous devez installer un fichier openssl.cnf valide sur votre système. Depuis PHP 4.3.0, une configuration simple est incluse dans le dossier openssl de la distribution Windows. Si vous utilisez PHP PHP 4.2.0 ou plus ancien, et que ces fichiers manquent, vous pouvez les télécharger sur » le site d'OpenSSL ou en téléchargeant les fichiers de configuration de PHP 4.3.0. PHP va rechercher le fichier openssl.cnf suivant la tactique suivante :
- La variable d'environnement OPENSSL_CONF, si elle est définie, sera utilisée comme chemin (comprenant le fichier) vers le fichier de configuration.
- La variable d'environnement SSLEAY_CONF, si elle est définie, sera utilisée comme chemin (comprenant le fichier) vers le fichier de configuration.
- Le fichier openssl.cnf sera supposé se trouver dans le dossier des certificats, tel que configuré lors de la compilation de la bibliothèque openssl. Cela signifie généralement c:\usr\local\ssl\openssl.cnf.
Dans votre installation, vous devrez décider si vous allez installer le fichier dans c:\usr\local\ssl\openssl.cnf ou si vous allez le faire ailleurs et configurer une variable d'environnement (possiblement par site virtuel). Notez qu'il est possible de remplacer le chemin par défaut en utilisant le paramètre configargs des fonctions qui requièrent un fichier de configuration.
Installation
24-Oct-2008 01:52
