Web Hosting Talk







View Full Version : Custom PHP.ini for Different Users


sprintserve
02-27-2003, 10:56 AM
Hi,

I was trying to use different php.ini for different virtual users.

What I had done:
1. I created a directory. Let's assumed /home/user1/config

2. I copied the php.ini into the above directory to form the base

3. In /home/user1/www/ , I created a .htaccess with the following line in it:

SetEnv PHPRC /home/user1/config

4. Restarted Apache

5. Created a PHP script with:

phpinfo();

6. I ran the PHP script and can still see that it is still using my default PHP.ini file at /usr/local/lib


Can anyone tell me where I went wrong? It seems everything is correct, and I can't seem to get it to work. Perhaps i need to sleep... in 4 days, I had less than 6 hours total.

If anyone can help, I will be deeply appreciative (and can sleep in peace :) )

Thanks.

sitekeeper
02-27-2003, 12:13 PM
Try adding this to a VirtualHost directive in the httpd.conf

php_value include_path .:/home/user1/path

and/or to the .htaccess

sprintserve
02-27-2003, 12:20 PM
I assume

php_value include_path .:/home/user1/config

?

I tried adding to .htaccess and get an internal server 500 error

I tried adding to httpd.conf and no difference.

sitekeeper
02-27-2003, 12:42 PM
Originally posted by sprintserve
I assume

php_value include_path .:/home/user1/config

?

I tried adding to .htaccess and get an internal server 500 error

I tried adding to httpd.conf and no difference.

I am sure you can have only 1 php.ini file but you can use the ini_set to make changes in the .htaccess

http://www.php.net/manual/en/function.ini-set.php

sprintserve
02-27-2003, 12:50 PM
I am aware of that. The function that I need to customise is mentioned as being able to be done only via php.ini. I read on some websites that customising by virtual users can be done.

And users of Ensim probably has this done pretty easily. But I am on Cpanel. So would appreciate any information.

RandallKent
02-27-2003, 05:57 PM
Hey SprintServe,

What are you trying to do with the edited php.ini? I was looking into this a few weeks ago to disable safe mode, and a few other oddities. I learned that you can only change some settings in a .htaccess. I still have a bunch of links saved from my searching, so I might have something that could help you.



Randy

sprintserve
02-27-2003, 05:59 PM
I am trying to allow some disable_functions variables. My default has the risky ones disabled. One of my clients fopen does not work as a consequence. I am trying to give only him access.

RandallKent
02-28-2003, 12:15 AM
Hey SprintServe,

Most likely, he's getting an error like
Warning: fopen("xxx/xxx", "r") - Operation not permitted in /xxx/xxx/xxx/xxx/ on line x

OR

Warning: SAFE MODE Restriction in effect. The script whose uid is xxx is not allowed to access /xxx/xxx owned by uid x in /xxx/xxx/xxx/xxx on line x

That can be solved by disabling safe mode on that account. You also might want to restrict the directories that he can access. Below is the code that you would need to put in his httpd.conf.

#disable safe mode
php_admin_value safe_mode Off

#where you want his fopen to work from (ie /home/virtual/sitexx on an Ensim box
php_admin_value open_basedir /xxx/xxx


Hopefully this will help. If this isn't what you were looking for, let me know :)


Randy

sprintserve
02-28-2003, 03:44 PM
I don't have safe mode in operation. And the function that I wish to override is disable_functions. But I found the solution. It's similar to your reply :) Thanks for the help.

sitekeeper
02-28-2003, 03:58 PM
Originally posted by sprintserve
I don't have safe mode in operation. And the function that I wish to override is disable_functions. But I found the solution. It's similar to your reply :) Thanks for the help.

sprintserve,

Could you please post your solution here so other members might benefit from it in the future.

Stomp442
02-28-2003, 04:13 PM
Originally posted by sitekeeper
sprintserve,

Could you please post your solution here so other members might benefit from it in the future.

Seconded.

.

sprintserve
03-01-2003, 12:02 AM
Ok. :) Here's the fix.

PHP works with both local values and master values . Those who had seen the phpinfo will understand what I am talking about. This is actually an useful way to custom for each customer.

While .htaccess works, it works for only *some* values.

So httpd.conf configuration is the way to go. Just add things such as

php_admin_value FUNCTION VALUE

in the virtual domain section for the user you want to customise for.

It's fairly straight forward :)

kennlee
05-13-2004, 12:44 PM
my main php.ini has disabled function fread for everyone.. but if i want to allow one virtual host to have access to the funtion fread, what do i need to put in php_admin_value disable_functions?

i tried putting in php_admin_value disable_functions none into the virtual host entry in httpd.conf, but it did nothing.. i still can't use fread (or any of the disabled functions) for that virtual host..

pls help. thanks.

sprintserve
05-21-2004, 10:42 PM
Do

php_admin_value disable_functions ""

in the virtual directory section for that user.

Zenutech
06-18-2004, 12:56 PM
Hi Sprintserve,

/usr/local/apache/bin/apachectl configtest
Syntax error on line 1204 of /usr/local/apache/conf/httpd.conf:
php_admin_value takes two arguments, PHP Value Modifier (Admin)

I have...

...
ErrorLog /home/someuser/logs/error_log
php_admin_value disable_functions ""
User someuser
Group somegroup

Please note that "none" such as
php_admin_value disable_functions none

IS recognize by php as being "" by looking at the phpinfo local value. However, local value seems to have absolutely no effect in overriding the master value. If anyone has ever successfully overriden the master value, please say so.

All I can think of is that I do not use phpsuexec so it is running as the web server. Perhaps local value needs to be ran as a specific user, although I have very high doubts (since php ships php without phpsuexec and it has local and master value built in automatically)

Please help.

EDIT: please note I have tried overriding the following disable_functions... phpinfo, echo, exec (just for testing purposes)