LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 02-01-2017, 02:35 PM   #1
MrMeeSeeks
Member
 
Registered: Jan 2017
Posts: 32

Rep: Reputation: Disabled
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.
 
Old 02-01-2017, 03:38 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Have a look at section titled 3 Custom php.ini For Each Web Site and let us know!

Have a read of /etc/apache2/mods-enabled/php5.conf
Don't change a damn thing in it.

Last edited by Habitual; 02-01-2017 at 03:40 PM.
 
Old 02-01-2017, 04:56 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
I actually came up with a very reliable strategy for doing this sort of thing, in my "straight CGI" legacy application, which I shamelessly "borrowed" from http://www.askapache.com/php/custom-...ps-and-tricks/.

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:
Code:
#!/bin/sh

export BLAH=BLAHBLAH
export BLAHHUMBUG=SCROOGE

exec /usr/bin/php-cgi --php-ini /my_webapp/php.ini $PATH_TRANSLATED
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.
 
Old 02-01-2017, 05:08 PM   #4
MrMeeSeeks
Member
 
Registered: Jan 2017
Posts: 32

Original Poster
Rep: Reputation: Disabled
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.

Guess I'll have to live with the mystery for now.
 
Old 02-01-2017, 05:13 PM   #5
MrMeeSeeks
Member
 
Registered: Jan 2017
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
I actually came up with a very reliable strategy for doing this sort of thing, in my "straight CGI" legacy application, which I shamelessly "borrowed" from http://www.askapache.com/php/custom-...ps-and-tricks/.

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:
Code:
#!/bin/sh

export BLAH=BLAHBLAH
export BLAHHUMBUG=SCROOGE

exec /usr/bin/php-cgi --php-ini /my_webapp/php.ini $PATH_TRANSLATED
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.
 
Old 02-01-2017, 06:05 PM   #6
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
As Habitual said, have a look in /etc/apache2/mods-enabled.

From my Debian box:
Code:
/etc/apache2$ ls -l mods-enabled/php*
lrwxrwxrwx 1 root root 29 Aug  1  2016 mods-enabled/php7.0.conf -> ../mods-available/php7.0.conf
lrwxrwxrwx 1 root root 29 Aug  1  2016 mods-enabled/php7.0.load -> ../mods-available/php7.0.load

/etc/apache2$ cat mods-available/php7.0.load 
# Conflicts: php5
# Depends: mpm_prefork
LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so
 
Old 02-01-2017, 06:06 PM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by MrMeeSeeks View Post
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.

http://php.net/configuration.file

Distro specific docs in /usr/share/doc/php5-common/

Last edited by Habitual; 02-01-2017 at 06:10 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
want to disable htaccess from updating the default php values set in php.ini nikeshp Linux - Software 2 05-26-2013 08:09 PM
[SOLVED] php.ini.rpmsave instead of php.ini ilvista Linux - Server 3 02-01-2011 04:39 PM
PHP won't recognize my Configuration File (php.ini) path kriezo Programming 4 02-14-2008 02:31 AM
php.ini-dist to php.ini lord-fu Programming 10 05-02-2006 05:24 PM
php5 apache2 mysql4 don't work, php does not seem to read php.ini atom Linux - Software 5 03-24-2005 11:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration