Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to read an environment variable in a ScriptAlias script. So I have SetEnv directives to set these variables, in the following apache configuration.

<VirtualHost *:80>
ServerName ...
DocumentRoot /srv/www
ServerAlias git
DocumentRoot /srv/www/git-web
<Location />
   # Crowd auth 
   AuthType Basic
   AuthName "Git repositories"
   AuthBasicProvider crowd
   CrowdAppName ...
   CrowdAppPassword ...
   CrowdURL http://localhost:8080/crowd/
   CrowdGroupsEnvName REMOTE_USER_GROUPS
   Require valid-user

SuexecUserGroup git git
SetEnv GIT_PROJECT_ROOT /home/dev_tools/git
SetEnv GITOLITE_HTTP_HOME /home/dev_tools/git

ScriptAliasMatch "(?x)^/(.*/(HEAD | info/refs | objects/(info/[^/]+ | [0-9a-f]{2}/[0-9a-f]{38} | pack/pack-[0-9a-f]{40}\.(pack|idx)) | git-(upload|receive)-pack))$" /srv/www/$1

<Directory /srv/www>
    Order allow,deny
    Allow from all

<Directory "/srv/www/git-web">
    Options ExecCGI
    AllowOverride None
    AddHandler cgi-script .cgi
    DirectoryIndex gitweb.cgi
    Order allow,deny
    Allow from all

In the script I see the environment variable declared in this file, but if I change it (add or remove a SetEnv directive, change one of the value, or add UnsetEnv directives) the shell script sees no change in its environment variables.

When I change the configuration I restart apache2 which indeeds reparse the file I changed (if i write unparseable content in this file apache2 tells me it could not start).

To see the environment in /srv/www/ I use:

printenv >> log_file

The following warning is given in for SetEnv directive:

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.

But I don't think I'm concerced by this warning since my script sees some environment variables and the SetEnv/ScriptAliasMatch is used by multiple tutorials to setup git on a http server.

Does anybody know why my log file is always filled with the same environemnt even when I change my apache2 configuration?

Server version: Apache/2.2.15 (Linux/SUSE) Server built: 2011-11-29 15:51:01.000000000 +0000

share|improve this question
up vote 0 down vote accepted

I succeeded in forwarding user variables via suexec by prefixing them with HTTP_ which is in the hardcoded list of authorized environment variables by suexec.

I'm quite surprized this is so a hidden behavior, I cannot even find again my sources on google.

Also, I still don't understand why the first values I set for other environment variables are still visible but cannot be changed.

But anyway, fixed my problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.