php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39316 extension_dir (in php.ini) has no effect in Windows
Submitted: 2006-10-31 04:49 UTC Modified: 2006-11-08 15:55 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: aren at cambre dot biz Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.1.6 OS: Windows Server 2003
Private report: No CVE-ID:
 [2006-10-31 04:49 UTC] aren at cambre dot biz
Description:
------------
extension_dir (in php.ini) has no effect in Windows. I installed a relatively clean installation of PHP 5.1.6 on Windows 2003. I configured the extension_dir line in php.ini using all these forms:
extension_dir = c:\PHP\ext
extension_dir = c:\php\ext
extension_dir = c:/PHP/ext
extension_dir = "c:\php\ext"

Regardless of the form used, php does not even attempt to search the c:\php\ext directory to find extensions.

Reproduce code:
---------------
1. Install php 5.1.6 on a clean Windows system. Only configure what is necessary to get it running. Be sure to set extension_dir to your actual ext directory. (Preferably, c:\php\ext.) Do a hello world php to test functionality.
2. Uncomment this line in php.ini:
extension=php_mysql.dll
3. Download the latest phpMyAdmin. Extract files and copy to a directory in your web server.
4. Get File Monitor from sysinternals (www.sysinternals.com).
5. Load File Monitor, and set its filter to php_mysql.dll. (This is so that it just reports on attempts to find php_mysql.dll and not hundreds of other filesystem hits.)
6. Start File Monitor so that it's catching filesystem hits.
7. Browse myPhpAdmin's index.php in a browser. You'll get an error saying that the mysql drivers cannot be used.
8. Go back to File Monitor. Notice how none of the directories searched were the directory specified in extension_dir.

Installing mySql is optional. Its presence has no effect on the above problem. (Of course, if the system actually found php_mysql.dll, then it would be a problem if mySql was not installed!)

Expected result:
----------------
phpMyAdmin should find the mySql extension, and File Monitor should confirm that php actually searches the c:\php\ext directory for the extensions.

Actual result:
--------------
Php searches all directories in the system path! extension_dir has no effect under Windows. You have to add c:\php AND c:\php\ext to the system path.

I think this is likely an application bug because the documentation is quite clear on how extension_dir should be configured.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-31 11:32 UTC] bjori@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-10-31 19:51 UTC] aren at cambre dot biz
That did not fix it. I deleted everything in C:\php, including directories, except for php.ini. Then I copied over the contents of php5.2-win32-latest.zip and did an iisreset (a command line program that restarts the web server).

By the way, it looks like php is checking a couple of additional directories besides those specified in the path. Here is my path (each directory on a separate line):
%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem
c:\Program Files\Intel\DMIX
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\
c:\Program Files\Microsoft SQL Server\90\Tools\binn\
c:\php

Here is what PHP checks:
C:\windows\system32\inetsrv\php_mysql.dll
C:\WINDOWS\system32\php_mysql.dll
C:\WINDOWS\system\php_mysql.dll
C:\WINDOWS\php_mysql.dll
C:\WINDOWS\system32\inetsrv\php_mysql.dll
C:\WINDOWS\system32\php_mysql.dll
C:\WINDOWS\php_mysql.dll
C:\WINDOWS\System32\Wbem\php_mysql.dll
C:\Program Files\Intel\DMIX\php_mysql.dll
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\php_mysql.dll
C:\Program Files\Microsoft SQL Server\90\Tools\binn\php_mysql.dll
C:\php\php_mysql.dll

PHP follows the path exactly starting with the 6th line. The first 5 lines are some unknown set of directories.

PHP checks those directories twice in a row.
 [2006-11-02 20:50 UTC] noah dot rusnock at echo-digitaldesign dot com
I have been dealing with this problem for months! I am using Windows XP SP2 with Apache 2.0.59 and PHP 5.1.6. I think I have had this issue since 5.1.4 or 5.1.3; I don't remember. I am new to PHP and Apache, but setup my own localhost server earlier this year (2006) and have had this problem from the beginning. (I added a vote, but submitted it as a 3; should be a 5; I need this working to start learning MySQL)
 [2006-11-02 21:54 UTC] noah dot rusnock at echo-digitaldesign dot com
I just setup a Windows 2000 SP4 virtual machine using Microsoft VirturalPC 2007 beta. I used the exact same setup as I did for my Windows XP (non-virtual machine) Apache server with PHP and I am still unable to load any extensions.
 [2006-11-08 14:27 UTC] tony2001@php.net
You are changing wrong php.ini.
Check phpinfo() to see which php.ini is used.
 [2006-11-08 15:16 UTC] aren at cambre dot biz
Wrong-o.

I loaded up filemon. You are correct that php is reading a php.ini in c:\windows. However, that file contains this line:
extension_dir = c:\PHP\ext

Next?
 [2006-11-08 15:17 UTC] aren at cambre dot biz
Oops, correcting the summary.
 [2006-11-08 15:29 UTC] tony2001@php.net
Please make sure you've put libmysql.dll into PATH, rebooted your webserver and if it still doesn't work, please show your phpinfo().
 [2006-11-08 15:55 UTC] aren at cambre dot biz
OK, the resolution is complicated.

http://us2.php.net/manual/en/install.windows.iis.php has a documentation error: "Modify the Windows PATH environment variable to include the PHP directory. This way the PHP DLL files, PHP executables, and php.ini can all remain in the PHP directory without cluttering up the Windows system directory. For more details, see the FAQ on Setting the PATH."

I did that, and contrary to what that says, PHP did not read  php.ini out of c:\php. It was reading it out of c:\windows. I did have a php.ini in c:\windows, but it may have been from a prior installation.

After creating a PHPRC environment variable (per the badly buried document at http://us2.php.net/manual/en/configuration.php#configuration.file), php started reading the correct c:\php\php.ini file, and things tentatively seem to be working correctly. (At least I am getting a different error from my application now!)

I have a separate bug report on the documentation error, so I will close this out.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 09:02:29 2014 UTC