Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. COI was able to get the script path to change using @bsdnoobz answer. So the path needs to be changed from Apache2 as I am not running in safe mode. I went to the apache2 dir but am unable to find the mod_env file. The documentation shows what i am wanting to do. But can you tell me how to do it . ie Add the entry to apache settings file. I am relatively very new to apache2 settings.
      singulars
    2. COThat depends on your os/httpd distribution. In general, first thing to do is checking if _LoadModule module_env_ is in _httpd.conf_ apache main configuration file. If it is, the module is loaded and active. Then, if you want the env variable to be available in the whole apache installation, put the directive in _httpd.conf_; if you want it available just for a site, put it inside a _VirtualHost_; or, you can put it in a .htaccess file, after granting _AllowOverride FileInfo_ to the relevant VirtualHost. Read about htaccess here: http://httpd.apache.org/docs/2.2/howto/htaccess.html
      singulars
    3. COI fired up phpinfo and it showed me that mod_env is loaded on my server. Next I went in to apache httpd.conf and edited `<Directory /> Options None AllowOverride None Order deny,allow Deny from all </Directory> ` to `<Directory /> Options None SetEnv PATH /usr/java/jdk1.6.0_31:/usr/apache-ant-1.8.3:/usr/apache-ant-1.8.3/bin:/usr/java/jdk1.6.0_31/bin AllowOverride None Order deny,allow Deny from all </Directory>` and restarted apache but I could not get the path to reflect change. Am i missing something
      singulars
 

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