Connecting Tech Pros Worldwide Help | Site Map

PHP5 as a CGI: how to set OPEN_BASEDIR per user using PHP.INI

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 26th, 2007, 03:25 PM
janvdberg@gmail.com
Guest
 
Posts: n/a
Default PHP5 as a CGI: how to set OPEN_BASEDIR per user using PHP.INI

Hi,

up until now I have used PHP4 as an Apache module which works lovely.
I used to have the following line per VHost for a userdir:
php_admin_value open_basedir /var/www/user/

This allowed users to only browse/open their own dir. Also I had a
couple of open_basedir entries in my global php.ini file like /tmp for
instance. So users could both open /tmp and /var/www/user?

Now I have switched to PHP5 as a CGI and I can't use the
"php_admin_value" settings anymore since running PHP as a CGI works
differently.
This however causes a problem for me: how do I set the specific
open_basedir per user?

I can't put the entries in the global php.ini because _all_ users will
be able to use this. So what I'd need is a way to use
a.) either a specific php.ini file per user. But how does this work:
I've tried putting a php.ini in the DocumentRoot -no effect.
b.) Rewrite the php.ini on the fly somehow, to add the userdir to the
list op open_basedir values when the PHP CGI is invoked.
c.) You tell me...

Any good pointers would be appreciated.


  #2  
Old February 28th, 2007, 09:55 AM
janvdberg@gmail.com
Guest
 
Posts: n/a
Default Re: PHP5 as a CGI: how to set OPEN_BASEDIR per user using PHP.INI

On Feb 26, 5:13 pm, janvdb...@gmail.com wrote:
Quote:
Hi,
>
up until now I have used PHP4 as an Apache module which works lovely.
I used to have the following line per VHost for a userdir:
php_admin_value open_basedir /var/www/user/
>
This allowed users to only browse/open their own dir. Also I had a
couple of open_basedir entries in my global php.ini file like /tmp for
instance. So users could both open /tmp and /var/www/user?
>
Now I have switched to PHP5 as a CGI and I can't use the
"php_admin_value" settings anymore since running PHP as a CGI works
differently.
This however causes a problem for me: how do I set the specific
open_basedir per user?
>
I can't put the entries in the global php.ini because _all_ users will
be able to use this. So what I'd need is a way to use
a.) either a specific php.ini file per user. But how does this work:
I've tried putting a php.ini in the DocumentRoot -no effect.
b.) Rewrite the php.ini on the fly somehow, to add the userdir to the
list op open_basedir values when the PHP CGI is invoked.
c.) You tell me...
>
Any good pointers would be appreciated.

Well just to reply to myself: I think I might have found something
useful.
The use of the "SetEnv PHPRC /var/www/user" in a .htaccess might help
me to set the PHP runtime environment and thus being able to choose
the location of the the php.ini file (which will allow me to use
different php.ini files).

However this doesnt seem to work for me in PHP 5.2.1. I can see with
phpinfo(); that my PHPRC is set/changed. However the php.ini from this
dir is _not_ picked up... it is still the default location. I don't
know why?

Other than this I know my own hosting provider (one.com) is able to
use a specific php.ini file for me _without_ using the PHPRC option.
This much becomes clear from the phpinfo(); So there is another way to
do this; but how?

 

Bookmarks

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.