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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • janvdberg@gmail.com

    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_valu e" 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.

  • janvdberg@gmail.com

    #2
    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:
    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_valu e" 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?

    Comment

    Working...