Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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"
    </Directory>

foo.php:

<?php
    var_dump($_SERVER["MYAPP_LOGGING_ROOT"]);
?>

Test:

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

 
discard

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.