Page 1 of 1

Local php.ini not being read

PostPosted: 10. March 2008 15:28
by microdove
I have XAMPP 1.6.6 installed, and PHP is working fine. However, I have noticed that the php.ini file from apache/bin is being used.

from phpinfo():

Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\Java\xampp\apache\bin\php.ini

Note that C:\Java\xampp is where I have installed XAMPP.

I have a php.ini file in each folder on my web site, but the files are being ignored for some reason. My understanding is that php is supposed to look for php.ini in the local folder first, then what is defined in the PHPRC environment variable (which does not appear to be defined on my system) and then the directory specified at compile time, which would be c:\windows.

Doing a global search for \php.ini in the XAMPP directory, I see a few places where the apache\bin\php.ini is found:

xampp-control.exe
xampp-control-default.exe
phpswitch.php

From the looks of the code, the phpswitch application merely changes out the php.ini file in apache\bin.

So, I am thinking that the executable files are controlling where php.ini is being read from, and it looks like it might be hard coded. Can anyone confirm if this is true? If so, is there any kind of override?

Thanks,
John

PostPosted: 10. March 2008 19:13
by sari42
>I have a php.ini file in each folder on my web site
IIRC only php.exe uses those files (see php.net)
but you can configure your folders to behave individually by means of .htaccess files (you even don't have to restart the webserver if you make any changes - very handy in the testing phase) like so:
Code: Select all
#boolean values:
php_flag display_errors On
#strings, variables:
php_value error_reporting 6143
#...

(you have to "AllowOverride All" in httpd.conf)

PostPosted: 10. March 2008 21:15
by Milligan

Thanks!

PostPosted: 11. March 2008 01:26
by microdove
I added the line:

Code: Select all
php_value auto_prepend_file "D:\Long Path Name\global-variables.php"


That fixed my original problem (have been doing that with php.ini).

Thanks!
John

PostPosted: 11. March 2008 01:37
by colbyt
Milligan wrote:PHP is compiled as an apache module in xampp and so it is not possible to use a local php.ini file because the php.ini file is only read once when apache starts.

Use a .htaccess file instead.

This post by Izzy explains why.
http://community.apachefriends.org/f/viewtopi ... 490#115490



I am far from an expert on the subject but I think whether a local file is read or not depends on how the allow_overide is set in Apache.