note 88816 modified in configuration.changes by danbrown
| From: | danbrown@php.net | Date: | Thu, 12 Feb 2009 03:35:04 +0000 |
| Subject: | note 88816 modified in configuration.changes by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150548@lists.php.net to get a copy of this message | ||
Running PHP under Apache poses a major problem when it comes to per-directory configuration settings
for PHP. In Apache virtual hosting, only a master PHP configuration file (i.e. php.ini) is parsed
at run-time per PHP script. Under IIS 6.0 or greater, you can include per-directory PHP
configuration files to override or overwrite the master configuration settings. The issue here,
however, is having Apache virtual hosts override/overwrite master settings; not what IIS can do.
So, there are two possible solutions. The first solution is described in this section and uses the
Apache configuration settings php_value, php_flag, php_admin_value, and php_admin_flag. In that,
each virtual host which you'd like to have certain configuration settings changed must have
these directives set (and that is for each PHP configuration setting). This, to me, is the more
viable solution, although it is time-consuming and mentally taxing.
The other possible solution is to set the PHPRC environment variable. To my knowledge, all
implementations of Apache HTTPD allow for the SetEnv directive to set the PHPRC variable
per-virtual-host. What that does is tell PHP to look in the specified location for that virtual
host's configuration settings file (i.e. "C:/path/to/custom/php.ini"). The only
downside to this tactic is that EVERY virtual host's custom php.ini file must contain all set
parameters. In other words, every single PHP configuration directive you have set in the master
php.ini file must ALSO be set in per-virtual-host configuration settings. Doesn't that suck?
It seems rather redundant to me (and completely defeats the purpose) that you have to include all
configuration settings OVER AND OVER AGAIN.
The great thing about per-directory configuration settings (when they're implemented correctly)
is that PHP already has the master settings pre-loaded and the per-directory settings (which may
only ammount to one directive in difference) can be loaded per request and, thus, there is less
over-head.
There really is more to this topic than that, which is why I blogged a rather lengthy and detailed
article here: http://hyponiq.blogspot.com/2009/02/apache-php-multiple-phpini.html
This information is meant to help users and administrators. I highly suggest it be read if anyone
has any questions on Apache and PHP configurations. I have included some examples that illustrate
the two possible solutions, as well. I did my best to research everything before I wrote the
article.
I hope this helps!
==== 10-FEB-09: ====
I must add a little more information:
I've done some thorough testing on my PC as to the PHPRC environment variable set by the Apache
directive SetEnv. It seems to me that this variable is completely disregarded using that directive.
I tried everything and can only come to the conclusion that either A) I did something very wrong,
or B) that it simply doesn't work as expected.
The former solution, however, does work magically! So, to expand on my previous post, the only real
and viable solution to this problem is to use the php_value, php_flag, php_admin_value and
php_admin_flag directives in your virtual hosts configurations.
Once again, it can be very boring! But it does work.
--was--
Running PHP under Apache poses a major problem when it comes to per-directory configuration settings
for PHP. In Apache virtual hosting, only a master PHP configuration file (i.e. php.ini) is parsed
at run-time per PHP script. Under IIS 6.0 or greater, you can include per-directory PHP
configuration files to override or overwrite the master configuration settings. The issue here,
however, is having Apache virtual hosts override/overwrite master settings; not what IIS can do.
So, there are two possible solutions. The first solution is described in this section and uses the
Apache configuration settings php_value, php_flag, php_admin_value, and php_admin_flag. In that,
each virtual host which you'd like to have certain configuration settings changed must have
these directives set (and that is for each PHP configuration setting). This, to me, is the more
viable solution, although it is time-consuming and mentally taxing.
The other possible solution is to set the PHPRC environment variable. To my knowledge, all
implementations of Apache HTTPD allow for the SetEnv directive to set the PHPRC variable
per-virtual-host. What that does is tell PHP to look in the specified location for that virtual
host's configuration settings file (i.e. "C:/path/to/custom/php.ini"). The only
downside to this tactic is that EVERY virtual host's custom php.ini file must contain all set
parameters. In other words, every single PHP configuration directive you have set in the master
php.ini file must ALSO be set in per-virtual-host configuration settings. Doesn't that suck?
It seems rather redundant to me (and completely defeats the purpose) that you have to include all
configuration settings OVER AND OVER AGAIN.
The great thing about per-directory configuration settings (when they're implemented correctly)
is that PHP already has the master settings pre-loaded and the per-directory settings (which may
only ammount to one directive in difference) can be loaded per request and, thus, there is less
over-head.
There really is more to this topic than that, which is why I blogged a rather lengthy and detailed
article here: http://hyponiq.blogspot.com/2009/02/apache-php-multiple-phpini.html
This information is meant to help users and administrators. I highly suggest it be read if anyone
has any questions on Apache and PHP configurations. I have included some examples that illustrate
the two possible solutions, as well. I did my best to research everything before I wrote the
article.
I hope this helps!
http://php.net/manual/en/configuration.changes.php