I believe you can get around this by using ordering preference in Apache.
In
/usr/local/apache/conf/includes/pre_main_global.conf add the lines:
Code:
<IfModule mod_suphp.c>
<Location />
suPHP_ConfigPath /path/to/php.ini
</Location>
</IfModule>
Note that
suPHP_ConfigPath should be just the directory location of the php.ini file. It should not be the full path to the php.ini file, just the full path to it's directory.
The
/usr/local/apache/conf/includes/pre_main_global.conf file may not exist or may be empty. That is fine, this file is already included in the Apache set up.
Restart Apache for the changes to go into affect.
/scripts/restartsrv_httpd
The
<Location> will override any suPHP_ConfigPath in the user's .htaccess file.
Then if a user needs a customized php.ini follow the instructions at:
http://forums.cpanel.net/361496-post10.html
That post deals mainly with enabling register_globals for an account, but you can change any values in the customized php.ini file for that account.
Very useful and helpful, although including it in pre_main_global.conf didn't work for me. It seemed to have no effect there.
In all of the scenarios below I am running Apache 2.x and wanting SSL and non-SSL vhosts to be affected.
Scenario #1: I want to force all users to use the primary php.ini file but i want a single user, bobdog, to have a custom php.ini file (/home/bobdog/php.ini)
a. create
/usr/local/apache/conf/userdata/suphp_configpath.conf containing:
Code:
#note: do not include php.ini itself - just the path - ex: /usr/local/lib/
<IfModule mod_suphp.c>
<Location />
suPHP_ConfigPath [B]/usr/local/lib/[/B]
</Location>
</IfModule>
b. create
/usr/local/apache/conf/userdata/std/2/bobdog/suphp_configpath.conf and
/usr/local/apache/conf/userdata/ssl/2/bobdog/suphp_configpath.conf, with each of those files containing:
Code:
#note: do not include php.ini itself - just the path to bobdog's homedir
<IfModule mod_suphp.c>
<Location />
suPHP_ConfigPath [B]/home/bobdog/[/B]
</Location>
</IfModule>
Scenario #2: I want to force all users to use the primary php.ini file but i want a single user, bobdog, to have a custom php.ini file, but only for bobdoglikescpanel.com, one of his 10 domains (/home/bobdog/public_html/bobdoglikescpanel.com/php.ini)
a. create
/usr/local/apache/conf/userdata/suphp_configpath.conf containing:
Code:
#note: do not include php.ini itself - just the path - ex: /usr/local/lib/
<IfModule mod_suphp.c>
<Location />
suPHP_ConfigPath [B]/usr/local/lib/[/B]
</Location>
</IfModule>
b. create
/usr/local/apache/conf/userdata/std/2/bobdog/bobdoglikescpanel.com/suphp_configpath.conf and
/usr/local/apache/conf/userdata/ssl/2/bobdog/bobdoglikescpanel.com/suphp_configpath.conf, with each of those files containing:
Code:
#note: do not include php.ini itself - just the path to the root web of bobdoglikescpanel.com
<IfModule mod_suphp.c>
<Location />
suPHP_ConfigPath [B]/home/bobdog/public_html/bobdoglikescpanel.com/[/B]
</Location>
</IfModule>
Then:
c.
/scripts/verify_vhost_includes
Check integrity of the include files I guess?
d. If #3 checks ok, then
/scripts/ensure_vhost_includes --all-users
Applies the vhost includes that apply to all users (i.e. in /usr/local/apache/conf/userdata/*.conf I guess) ?
e.
/scripts/ensure_vhost_includes --user=bobdog
Applies the specific vhost includes for user bobdog and his domains I guess?
At any rate, this worked for me. All the sites on the server are restricted to using only the default php.ini in /usr/local/lib/php.ini except for bobdog, who either gets a custom php.ini to use for all of his domains (scenario #1) or a single domain of his (scenario #2).
If some other user attempts to drop a php.ini file in their own directory structure, it is ignored.
With all of that said, I'm not sure why it didn't work for me when I put it in pre_main_global.conf.
For others reading, keep in mind that It can even be made more secure by having the users' custom PHP files outside of their homedirs to where only the admin can access/modify them - i.e. exactly what Sparek described how to do in a link he posted earlier in this thread.
I also have not figured out yet if a newly added user automatically has that include applied to them as well, or if I would have to re-run
/scripts/ensure_vhost_includes --all-users each time I add a new user. I'm hoping it's automatic. I need to delve further into the Twiki info.
Thanks, Sparek, for your tutorial on how to do this.
Mike