Re: Environment variables in php.ini

From: Date: Fri, 30 Mar 2007 21:53:28 +0000
Subject: Re: Environment variables in php.ini
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-251805@lists.php.net to get a copy of this message
Abdullah Ramazanoglu wrote:
Hello, I have a Linux shared hosting environment with PHP running over CGI. With CGI I can't use httpd.conf or .htaccess files for PHP related parameters, so all the parameters should be given in one central php.ini file, AFAIK. So how can I give parameters, in effect, like the ones below? error_log = $HOME/php_error.log session.referer_check = $DOMAIN_NAME open_basedir = "$HOME:/usr/lib/php:/usr/local/lib/php:/tmp" session.save_path = $HOME/sessions With PHP module SAPI I would have overridden them in httpd.conf VirtualHost directive with hard coded values. There, I don't have to use variables as every vhost has its own VirtualHost section. But I don't know how to do it (or if it is possible at all) in CGI mode. Actually I did find a raw solution: Put a custom php.ini in each virtual host's Doc_Root. But I don't really want to allow virtual hosts each having a custom php.ini in their home directories, as that solution has several serious drawbacks, like: - No server/security policies can be enforced, - An intruder can change the local php.ini and remove all the security measures, - Hundreds of php.ini files strewn around can easily lead to chaos, - etc. Is it possible at all to use environment variables in php.ini, or is there any other solution to the problem above? Thank you.
Read this: http://us3.php.net/manual/en/configuration.php#configuration.file You can put a file in any other these locations that will be read by the cgi when it is started. my suggestion would be to use a single php.ini file in a global location. Then symlink a php.ini to there home directory or web root. Then set perms on the single global file such that only you can write to it, but everybody can read it. This should work for you. -- Enjoy, Jim Lucas Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree. - Rush

« previous php.general (#251805) next »