Forum Moderators: coopster

Message Too Old, No Replies

php.ini "current working directory" setting not being followed

php.ini can exist in multiple places.. why can't I use this one?

         

broniusm

3:44 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



This comment is at the top of /etc/php.ini
; This file controls many aspects of PHP's behavior. In order for PHP to
; read it, it must be named 'php.ini'. PHP looks for it in the current
; working directory,
in the path designated by the environment variable
; PHPRC, and in the path that was defined in compile time (in that order).

It's my understanding from the above that if I put a new php.ini in multiple subdirectories anywhere within my site, that I can effectively override the system default settings? Why does it appear that this is not the case?

Also, will php.ini override all settings or be "merged" with /etc/php.ini?

thanks!

coopster

7:04 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



php.ini is read into memory when Apache is started (module version at least).

Here it is ...


The configuration file (called php3.ini in PHP 3, and simply php.ini as of PHP 4) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI version, it happens on every invocation.

If you are trying to use different settings for different sites, you need to override the php_value settings in your Apache <VirtualHost> containers (for those directives that allow overrides).

Resources:
Runtime Configuration [php.net]
How to change configuration settings [php.net]
php.ini directives [php.net]

broniusm

3:48 am on Aug 6, 2005 (gmt 0)

10+ Year Member



ok, that makes sense.. I was thinking it was equiv to CF where placing Application.cfm in any directory will determine behavior for that directory and below.. It's cool, but kind of hap-hazard if you ask me: that's what you get when Macromedia tries to teach designers to develop ;)

thanks for the response. I might need to learn how to turn on .htaccess instead if necessary, eh.

coopster

1:04 pm on Aug 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, per-directory overrides (.htaccess) will work for some, but not all directives. The details are in the last link. There is a column named "Changeable" that tells you where any given directive can be set. Then, at the bottom of the page in a table called "Table H-2. Definition of PHP_INI_* constants" you can read about the details.