Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'm running into some trouble figuring out how I should handle something under FastCGI that worked pretty easily under mod_php. Before I was using SetEnv to pass options from my VirtualHost directive to my PHP application. For example:

SetEnv MYAPP_LOGGING_ROOT "/usr/local/myapp/logs"

I was able to access this value from $_SERVER['MYAPP_LOGGING_ROOT'] and it was a pretty convenient way to do manage this. However, this value is not being passed to my PHP application in a FastCGI environment.

I tried the following but it does not appear to be passing all the way down to my PHP application either:

FcgidInitialEnv MYAPP_LOGGING_ROOT "/usr/local/myapp/logs"

Am I missing something simple or do I need to be doing something more complex?

share|improve this question
up vote 0 down vote accepted

SetEnv work with mod-fcgid. My config:

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
            FCGIWrapper /usr/lib/cgi-bin/php5
            AddHandler fcgid-script .php
            Options ExecCGI Indexes
            SetEnv MYAPP_LOGGING_ROOT "/usr/local/myapp/logs"




curl localhost/foo.php 
string(21) "/usr/local/myapp/logs"
share|improve this answer
Your answer encouraged me to do some more debugging and found that there was an error elsewhere in my code that was obscuring my original SetEnv command. – Beau Simensen Mar 2 '11 at 5:14

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.