# How can I use SetEnv with mod_fcgid to pass virtualhost specific options to my PHP application? (apache2)

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? ## 1 Answer 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"

• 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