1

I have a php setting that can only be changed in the ini file. I can't change this setting in the global php.ini due to conflicts, so I'll need to have this user specific. Can this be done if php is ran as a module? Or must I change php run as a cgi?

Seems like the best answer is "not really", but you can sneak around changing some parameters using tricks below.

5 Answers 5

2

I'm not aware of any way to specify a separate php.ini when using PHP as an Apache module, only when using PHP as a CGI. That said any of the configuration options in the php.ini can be changed in the .htaccess file as shown at http://php.net/configuration.changes so long as you have AllowOverride set in the Apache config set to Options or All.

I've done this on many of my sites to change common PHP configurations. I would assume that you're not needing to change every setting so the number should be easily managed by adding the options to your .htaccess file within the directory you need the changes in.

The following is one I use on a couple sites to change the include_path as well as set the auto_prepend_file and auto_append_file settings. For boolean flag items just use php_flag instead of php_value.

<IfModule mod_php5.c>
    php_value auto_prepend_file 'header.inc.php'
    php_value auto_append_file 'footer.inc.php'
    php_value include_path '/path/to/private/includes:/usr/share/pear'
</IfModule>
1
  • This is good, but the value I need to change is a php.ini only
    – SeanDowney
    Jul 10, 2009 at 17:29
1

I overrode the handler for php for a php cgi wrapper and was able to specify a php.ini file

To do this: create a htaccess file in the folder you wish to modify with something like this:

Action php5-cgi /cgi-bin/php5-cgi.cgi
AddHandler php5-cgi .php

Then create a file 'php5-cgi.cgi' with something like this:

#!/bin/sh
exec /usr/bin/php-cgi "$@" -c "/home/user/php.ini"

Set Permissions on this file to execute as the "user". Then run a test file with phpinfo(1); to see if you have your ini file loaded.

Thanks for everyones help!!

0

All details are here : http://php.net/configuration.changes

6
  • That is helpful for changing php.ini settings, but it doesn't say if one would be allowed to change the ini file itself. I'm trying to change a setting that is php.ini only
    – SeanDowney
    Jul 9, 2009 at 22:40
  • What is the setting you want to change ?
    – radius
    Jul 9, 2009 at 22:48
  • Well really what I'm trying to do is use two different 'zend_extension' settings which conflict with each other (xdebug & zend optimizer). I would like to use the xdebug globally and only the zend optimizer in the account that requires it
    – SeanDowney
    Jul 9, 2009 at 23:04
  • Ok, I see, you can run php as cgi but it will be slow. I would suggest to start 2 instance of apache (eg. one running on port 8080 and the other on 8081) each one with the php settings you want. Then use another apache (or any other software than can do reverso proxy) instance on port 80 acting as a reverse proxy to both apache. Of course this is a less easy things to setup.
    – radius
    Jul 9, 2009 at 23:13
  • Well, that sounds crazy, but i'll look into that. Since you know your stuff, is is possible to reassociate php files with a different handler which runs a could be a cgi version of php? I was reading this online but didn't really understand if it would even apply.
    – SeanDowney
    Jul 10, 2009 at 0:32
0

Basically, no.

From the PHP manual:

The configuration file (php.ini) 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.

0

You may use Apache "php_admin_value" per vhost/user.

IIRC, you may redefine every php.ini value using this command

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .