|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Your comment was added to the bug successfully.
Bug #42849 Configuration File (php.ini) Path incorrect
Submitted: 2007-10-04 07:37 UTC Modified: 2010-05-28 00:23 UTC
Avg. Score:4.5 ± 0.9
Reproduced:56 of 57 (98.2%)
Same Version:22 (39.3%)
Same OS:32 (57.1%)
From: inglis-php at yahoo dot com dot au Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.4 OS: win xp pro
Private report: No CVE-ID: None
 [2007-10-04 07:37 UTC] inglis-php at yahoo dot com dot au
I have just used the .msi file to install php 5.2.4  All appeared to work well. I installed to c:\PHP folder. Then wrote a small .php test file (below) and tried it and the noticed that: 
The phpinfo() function is reporting php.ini file as being in the 'C:\Windows' directory.  It is actually located in 'C:\PHP' directory. I have searched my c drive and there is only one copy of php.ini and it is in the c:\PHP directory.  I assume it finds the php.ini via the path environment which now starts with c:\PHP.

Reproduce code:
  <title>PHP Test</title>
 <?php echo '<p>Hello World</p>'; ?> 
<?php phpinfo(); ?> 

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-05 15:23 UTC]
Exactly what does phpinfo() have about php.ini? There are 2 places in the output, paste both here..(in the very beginning of the output..)

 [2007-10-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-12-01 15:55 UTC] rafael dot amador at gmail dot com
Bug #37919 PHP <---- The same bug
 [2008-12-01 15:59 UTC] rafael dot amador at gmail dot com
Bug #39191
 [2008-12-11 06:22 UTC] yaddayadda at mailinator dot com
I'm a new user of PHP/MySQL. I installed both and phpMyAdmin with no deviation from the instructions and could not get phpMyAdmin to work at all (it could not load the mysql extension). Despite reading numerous posts about what to uncomment in php.ini and what to add to the PATH, whatever I did did not seem to have any effect. Only after I ran phpinfo() did I find out that the path to php.ini was somehow pointing the Windows folder. I was editing php.ini in C:\PHP. 

There are many, many frustrated students and beginners out there having this exact issue. They don't know it is a bug. They are told to "just copy php.ini to your Windows folder" as a fix. I did not want to do this because I set the PATH to C:\PHP so I knew it should be looking there and NOT in C:\Windows (because there was no php.ini there, it should continue looking through the locations specified in PATH). I still do not know how to change this and ended up moving the file out of frustration and everything began to work. 

So many people are experiencing this frustration and wasting hours trying to fix it. Some are even giving up and moving to hosts that already have PHP installed rather than continue to learn on their own. If you install PHP to C:\PHP, the php.ini file it looks for should be there!
 [2009-09-05 03:57 UTC] headnok at yahoo dot com
I had the same damn problem and was pulling my hair out for a week.  Please!!! Either instruct the users to move the php.ini file into the C:\windows directory your installation instructions or fix the problem!  Please!!!
 [2009-09-16 18:41 UTC] misc at imerk dot net
I've just run into this problem. Using win2k8 r2 x64. And php 5.2.5

I copied the php installation that is working on a win2k3 server to this 
win2k8 box. I put the path to the ini file in both the system PATH 
variable as well as creating a reg key in 
local_machine/software/php5/iniFilePath = C:\php5

I still get (none) for the loaded config file. This is working fine on 
the win2k3 machine though.
 [2009-10-12 11:48 UTC] alim at fourplusadvertising dot com
I am quite confused with this whole thing on my mac (leopard).. i thought my PHP was the perfect installation..;-).. till i realised that my PHP.ini setting of upload_max_filesize was still 2 MB inspite of me having changed it to 32 MB!!..

how do i get php to use the php.ini values and not the default.. I am facing the same issue on my imac.. there's some loaded configuration file which shows /private/etc while the Configuration File (php.ini) Path is /etc

But they are I think symlinked.. but whatever I edit in the php.ini does not reflect in the phpinfo()..

please help..
 [2009-12-28 05:33 UTC] u2gohome at gmail dot com
Hi. For me this problem was only occurring when php was executed via apache. Executing php -i from the command line listed the mysql extension whereas a phpinfo() request via the browser did not. 

Try adding the following line to your apache httpd.conf file (to point to the directory containing php.ini) eg.

PHPIniDir 'C:\php'

Adding this line changed phpinfo()'s reported 'Loaded Configuration File' from (none) to C:\php\php.ini, and mysql started talking. However, phpinfo() still reports c:\windows as the php.ini directory.

Cheers, Matt
 [2010-03-18 23:30 UTC] rsberger1 at hotmail dot com
Since this bug was suspended due to "no feedback", I thought I'd supply
the requested feedback and hope that someone would fix this annoyance.

The two places in my phpinfo output regarding php.ini are:

Configuration File (php.ini) Path 	C:\Windows
Loaded Configuration File 	        D:\Apps\MyFolder\php-5.3.2\php.ini

Apparently my php.ini is being loaded from my php-5.3.2 folder, but
phpinfo erroneously reports php.ini's path as C:\Windows.
 [2010-05-28 00:06 UTC] vera_cai at hotmail dot com
I have exactly the same problem that because of this bug, my PHP just can not work with mysql and keep complainning "Call to undefined function mysql_connect() ". 

I've tried 5.2.13, 5.3.2 and both had problem. Until searched forum with somebody mentioned to use "phpinfo" check where the php.ini located, I eventually find this bug. With one line added in httpd.conf file "PHPIniDir 'c:\php'", the problem is gone. 

Can somebody help to fix this problem as this is not only annoying, I 
am not able to get PHP work with mysql because of this.
 [2010-05-28 00:23 UTC]
-Status: No Feedback +Status: Bogus
 [2010-05-28 00:23 UTC]
Ask support in the PHP setup or PHP Windows mailing. Or to one of the numerous support channel out there.
 [2012-04-28 03:46 UTC] zzz20120427 at pby dot com
After installing PHP 5.2.14 via the msi installer, Apache 2.2.16 would no longer start - until I tried the PHPIniDir 'C:\Program Files\PHP' trick (single quotes and backslashes).  But PHPInfo showed Configuration File (php.ini) Path as C:\Windows and Loaded Configuration File as (none).  (I have only one PHP.ini file and it's in C:\Program Files\PHP.)

Double-checking with PHP -i, I got several dialog boxes warning that the built-in dlls weren't loaded.  PHPInfo showed an incorrect default directory for include_path so I uncommented include_path and set it to C:\Program Files\PHP\PEAR.  No idea if this is correct but the dialog boxes went away, but only if I didn't use a terminating quote!  (Otherwise Apache wouldn't start.)

I also noticed that Loaded Configuration File was now displaying correctly - whether I used slashes or backslashes, double-quotes or single-quotes.  Unfortunately, PHPInfo did not show the modules I had enabled in PHP.ini.

I wonder why PHP will let Apache start with three quotes and not four.  Here are the settings I made (I switched to forward slashes so the trailing backslash of a Windows path could not accidently escape the quote.
PHPIniDir "C:/Program Files/PHP/"

include_path = ".;C:/Program Files/PHP/PEAR

BTW, moving the trailing quote from PHPIniDir to PHP.ini prevented Apache from starting.
 [2012-04-30 22:10 UTC] zzz20120427 at pby dot com
Well, I achieved success, but didn't pin down the bug.

I stripped *everything* out of my php.ini except the active lines, comparing them to the working Windows 7 machine (from which I copied the Apache and PHP installers that fail on this Windows 7 machine).

The PHP msi must have added "C:\Program Files\PHP\;" to my PATH, and added "PHPRC=C:\Program Files\PHP\" to my environment variables.  This would have been a despised absolute last resort for me, but it led me to comment out PHPIniDir "C:/Program Files/PHP/" in httpd.conf.  Apache and PHP still started with the still-unterminated (by a quote) include_path string in php.ini.

As a crude solution, I tried moving include_path to the end of the file so that all the stuff after it wouldn't be added to include path.  Apache wouldn't start.  Putting it back, I began moving it downward to try find the point where it fails.  It first failed in the [PHP_EXIF] section, so I commented out the extension=php_exif.dll.  It failed again in the [PHP_MSSQL] and [PHP_PDO_MSSQL] sections; commented those extensions too.  There were no more crashes as I moved further down the file so I put the include_path back in its original position; all was well.  Then, I added the terminating quote to the include_path - it worked!  All of the modules appeared in phpinfo.php.  It still (correctly) shows Loaded Configuration File as C:\Program Files\PHP\php.ini but doggedly continues to show Configuration File (php.ini) Path as C:\Windows.  (Afterward, I restored PHPIniDir to httpd.conf which caused no change.)

Funny thing: once I got it working, PHP finally began writing errors to its error log.  Thanks alot, eh?  (The errors were a missing browscap.ini file that I had just added to the php.ini  It's gone now.)

Perhaps those three modules load C:\Program Files\PHP\PEAR\go-pear.phar and that module objects to the close quote on include_path, which causes everything else to go wrong?  Curiously, my other Windows 7 machine doesn't object to PHP_MSSQL or PHP_PDO_MSSQL.

I hope this provides some clues to the developers.  It may not be quite the bug reported but it was a sympton of another bug I was researching.

Apache installer:
PHP installer:
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC