which script determines which php.ini is included when PHPIniDir is unset? //using apache2
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
which script determines which php.ini is included when PHPIniDir is unset? //using apache2
So the internet exhaustively tells anyone who's interested, how to include the PHPIniDir-Directive in the apache-conf to change which php.ini is included on startup.
But I failed trying to just figure out where the ini is set/included in the first place, because that definitely shouldn't be said http.conf, since there is only a general include-php directive there as it stands and my ini is included all right.
Sorry for the stupid question, by the way.
Last edited by MrMeeSeeks; 02-01-2017 at 02:38 PM.
The voodoo actually requires three Apache directives to cause a custom-script to be invoked:
Code:
# First, specify a custom action for php files. (Individual "<VirtualHost>" entries can override this.)
AddHandler my-webapp-php .php
# Direct each handler to the corresponding custom executable. Must use the "Alias" here ...
Action my-webapp-php /frobozz-cgi/my-webapp-php.cgi virtual
# This is the alias that must be used with the Action. Equate it to a physical directory.
ScriptAlias /frobozz-cgi/ /my_script_directory/
Now, my-webapp-php.cgi must be an executable script that sets up the call like this:
So, as you can see, Apache first invokes my script, instead of PHP itself. This script sets up the environment and, via exec, replaces itself with an instance of PHP having the proper command-line parameter to select a php.ini file of my own choosing.
In this way, and no matter what the environment otherwise would have stated, the launch sequence of every PHP script in the application is placed under my control, including specification of the ini-file that is to be used.
Last edited by sundialsvcs; 02-01-2017 at 05:06 PM.
Well the site you linked is about the same thing, isn't it? It describes the PHPIniDir-Directive, just in the context of Virtual Hosts. What I meant is: I never set this directive and there is none set by default in the httpd.conf, but Apache still knew which php.ini to include and that kind of bothers me.
I have php7 installed by the way, which seems to have kept out of /etc entirely. I've skimmed through anything that would resemble such a config file (find would find no php7.conf though), but found nothing enlightening.
The voodoo actually requires three Apache directives to cause a custom-script to be invoked:
Code:
# First, specify a custom action for php files. (Individual "<VirtualHost>" entries can override this.)
AddHandler my-webapp-php .php
# Direct each handler to the corresponding custom executable. Must use the "Alias" here ...
Action my-webapp-php /frobozz-cgi/my-webapp-php.cgi virtual
# This is the alias that must be used with the Action. Equate it to a physical directory.
ScriptAlias /frobozz-cgi/ /my_script_directory/
Now, my-webapp-php.cgi must be an executable script that sets up the call like this:
So, as you can see, Apache first invokes my script, instead of PHP itself. This script sets up the environment and, via exec, replaces itself with an instance of PHP having the proper command-line parameter to select a php.ini file of my own choosing.
In this way, and no matter what the environment otherwise would have stated, the launch sequence of every PHP script in the application is placed under my control, including specification of the ini-file that is to be used.
Well, that seems like a neat solution to a problem I currently don't have, but thanks a lot for sharing, I'll keep it for future reference.
I was actually asking out of sheer interest - the standard .ini is working just fine for my current needs, I just wondered how apache knows where to find it since it is not included via the directive in httpd.conf. So Apache must know through something that happened by default while either it or php was configured I guess, and now stores the information in some mystical place not for me to see.
Last edited by MrMeeSeeks; 02-01-2017 at 05:18 PM.
I just wondered how apache knows where to find it since it is not included via the directive in httpd.conf. So Apache must know through something that happened by default while either it or php was configured I guess, and now stores the information in some mystical place not for me to see.
/etc/php5/apache2/php.ini says right on the box:
Code:
; See the PHP docs for more specific information.
; http://php.net/configuration.file
More Specific information is what I'd call authoritative.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.