Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For setting environment variables in php, let me refer to official putenv documentation:</p> <blockquote> <p>Adds setting to the server environment. <strong>The environment variable will only exist for the duration of the current request.</strong> At the end of the request the environment is restored to its original state.</p> <p>Setting certain environment variables may be a potential security breach. <strong>The safe_mode_allowed_env_vars directive contains a comma-delimited list of prefixes. In Safe Mode, the user may only alter environment variables whose names begin with the prefixes supplied by this directive.</strong> By default, users will only be able to set environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). Note: if this directive is empty, PHP will let the user modify ANY environment variable!</p> <p>The safe_mode_protected_env_vars directive contains a comma-delimited list of environment variables, that the end user won't be able to change using putenv(). These variables will be protected even if safe_mode_allowed_env_vars is set to allow to change them.</p> </blockquote> <p>I think that is definitely not the way to go, if not very particular cases; on the other hand setting environment variables in httpd configuration is very easy, using module <code>mod_env</code>'s <code>SetEnv</code> directive:</p> <blockquote> <p><strong>SetEnv Directive</strong></p> <pre><code>Description: Sets environment variables Syntax: SetEnv env-variable value Context: server config, virtual host, directory, .htaccess Override: FileInfo Status: Base Module: mod_env </code></pre> <p>Sets an internal environment variable, which is then available to Apache HTTP Server modules, and passed on to CGI scripts and SSI pages.</p> <p>Example</p> <pre><code>SetEnv SPECIAL_PATH /foo/bin </code></pre> <p>The internal environment variables set by this directive are set after most early request processing directives are run, such as access control and URI-to-filename mapping. If the environment variable you're setting is meant as input into this early phase of processing such as the RewriteRule directive, you should instead set the environment variable with SetEnvIf.</p> </blockquote> <p>Ah they can go almost everywhere, from main httpd.conf, to virutal host configurations, or even in htaccess when FileInfo override is granted, they turn out to be very versatile.</p> <p>Refs:</p> <ul> <li><a href="http://httpd.apache.org/docs/2.2/env.html" rel="nofollow">http://httpd.apache.org/docs/2.2/env.html</a></li> <li><a href="http://httpd.apache.org/docs/2.2/mod/mod_env.html" rel="nofollow">http://httpd.apache.org/docs/2.2/mod/mod_env.html</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload