Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #12638 > unrolled thread

php.ini loading

Started byScott Johnson <noonehome@chalupasworld.com>
First post2014-01-12 19:25 -0800
Last post2014-01-13 16:05 -0800
Articles 5 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  php.ini loading Scott Johnson <noonehome@chalupasworld.com> - 2014-01-12 19:25 -0800
    Re: php.ini loading Jerry Stuckle <jstucklex@attglobal.net> - 2014-01-12 22:41 -0500
    Re: php.ini loading jnorth.au@example.com - 2014-01-13 14:46 +1100
    Re: php.ini loading Arno Welzel <usenet@arnowelzel.de> - 2014-01-13 15:42 +0100
    Re: php.ini loading Scott Johnson <noonehome@chalupasworld.com> - 2014-01-13 16:05 -0800

#12638 — php.ini loading

FromScott Johnson <noonehome@chalupasworld.com>
Date2014-01-12 19:25 -0800
Subjectphp.ini loading
Message-ID<lavmau$u3o$1@dont-email.me>
I am running PHP as an Apache Module.

PHP 5.2.6

On my local server it is loading the php.ini from C:\Windows\php.ini

I am having 2 issues that I can hope to resolve.

1. I would prefer it to load from the working directory which getcwd() 
shows to be my site root (as expected).  This was never a problem before 
but I need to have some independent configs since my clients are across 
different servers.

The config text says it will look for it in the working directory which 
I think brings me to issue 2.

2.  The php.ini only reloads when I restart the apache server not on 
each page call which I think is why it is loading the default.

When I changed the config on the production server it would reflect it, 
but not on the local.

So in a nut shell I would like to have the config file loaded from my 
working directory on each invocation of a php page.

Is this possible or am I looking at this all wrong?

Thanks
Scotty

[toc] | [next] | [standalone]


#12639

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-01-12 22:41 -0500
Message-ID<lavn8u$2dv$1@dont-email.me>
In reply to#12638
On 1/12/2014 10:25 PM, Scott Johnson wrote:
> I am running PHP as an Apache Module.
>
> PHP 5.2.6
>
> On my local server it is loading the php.ini from C:\Windows\php.ini
>
> I am having 2 issues that I can hope to resolve.
>
> 1. I would prefer it to load from the working directory which getcwd()
> shows to be my site root (as expected).  This was never a problem before
> but I need to have some independent configs since my clients are across
> different servers.
>
> The config text says it will look for it in the working directory which
> I think brings me to issue 2.
>

Hi, Scotty,

You do NOT want to have your php.ini file ANYWHERE under a 
DOCUMENT_ROOT.  That is a huge security exposure.

And what's wrong with where it is?  PHP will use the same php.ini file 
for all invocations if you're running it as an Apache module.  You won't 
get different ones for different websites.

> 2.  The php.ini only reloads when I restart the apache server not on
> each page call which I think is why it is loading the default.
>

That is correct operation.  Parsing it for every page would be 
unnecessary overhead.

> When I changed the config on the production server it would reflect it,
> but not on the local.
>

Are you running PHP as an Apache module on the production server?


> So in a nut shell I would like to have the config file loaded from my
> working directory on each invocation of a php page.
>
> Is this possible or am I looking at this all wrong?
>
> Thanks
> Scotty
>
>

It is not possible (and not advisable).

But you can put additional PHP options in your Apache configuration file 
(and .htaccess if it Apache is configured to use it).  You can't change 
some things (like which external modules are loaded), but you can most 
options.  See http://www.php.net/manual/en/ini.list.php for more 
information.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#12640

Fromjnorth.au@example.com
Date2014-01-13 14:46 +1100
Message-ID<6co6d9d534vj34ol4m2ggk797rhr9lmadk@4ax.com>
In reply to#12638
On Sun, 12 Jan 2014 19:25:24 -0800, Scott Johnson <noonehome@chalupasworld.com> wrote:

>I am running PHP as an Apache Module.
>
>PHP 5.2.6
>
>On my local server it is loading the php.ini from C:\Windows\php.ini
>
>I am having 2 issues that I can hope to resolve.
>
>1. I would prefer it to load from the working directory which getcwd() 
>shows to be my site root (as expected).  This was never a problem before 
>but I need to have some independent configs since my clients are across 
>different servers.
>
>The config text says it will look for it in the working directory which 
>I think brings me to issue 2.
>
>2.  The php.ini only reloads when I restart the apache server not on 
>each page call which I think is why it is loading the default.
>
>When I changed the config on the production server it would reflect it, 
>but not on the local.
>
>So in a nut shell I would like to have the config file loaded from my 
>working directory on each invocation of a php page.
>
>Is this possible or am I looking at this all wrong?
>
>Thanks
>Scotty
>

I'm not sure if this answers your question:
http://hyponiq.blogspot.com.au/2009/02/apache-php-multiple-phpini.html

[toc] | [prev] | [next] | [standalone]


#12647

FromArno Welzel <usenet@arnowelzel.de>
Date2014-01-13 15:42 +0100
Message-ID<52D3FB6F.1090802@arnowelzel.de>
In reply to#12638
Am 13.01.2014 04:25, schrieb Scott Johnson:

> I am running PHP as an Apache Module.
> 
> PHP 5.2.6
> 
> On my local server it is loading the php.ini from C:\Windows\php.ini
> 
> I am having 2 issues that I can hope to resolve.
> 
> 1. I would prefer it to load from the working directory which getcwd() 
> shows to be my site root (as expected).  This was never a problem before 
> but I need to have some independent configs since my clients are across 
> different servers.

This would be a huge security hole! You don't want your php.ini there!

> The config text says it will look for it in the working directory which 
> I think brings me to issue 2.
> 
> 2.  The php.ini only reloads when I restart the apache server not on 
> each page call which I think is why it is loading the default.

Yes - because PHP is loaded as Apache module. This means that Apache
will only load the PHP module *once* and not for every single request.

> When I changed the config on the production server it would reflect it, 
> but not on the local.
> 
> So in a nut shell I would like to have the config file loaded from my 
> working directory on each invocation of a php page.

Why?

1) You can use ini_set() (see
<http://php.net/manual/de/function.ini-set.php>) to override settings if
needed.

2) You can use an .htaccess file to override PHP settings if needed

3) You can use PHP as CGI and not module - so it will be loaded for
every request and therefore load the settings as well for every request.
I would not recommend this for production sites due to the worse
performance compared to the module (which only has to be loaded once
when Apache starts) - but for testing purposes this should be OK.

4) You can use PHP with FastCGI using mod_fcgi and an appropriate
wrapper script, if you need specific settings for one site where you
pass the site specific php.ini to the PHP runtime (and/or customized
settings for the site)



-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de

[toc] | [prev] | [next] | [standalone]


#12650

FromScott Johnson <noonehome@chalupasworld.com>
Date2014-01-13 16:05 -0800
Message-ID<lb1uvg$h9v$1@dont-email.me>
In reply to#12638
On 1/12/2014 7:25 PM, Scott Johnson wrote:

<snipped>

Thanks to everyone for suggestions.

Not sure why I had it in my brain to load separate configs since it has 
never been an issue previously.

On further thought and study it would be a security issue as Jerry and 
Arno pointed out.

Thanks for clearing the cob webs.

Scotty


[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web