I have writen a fastcGI application using C and C++
I have a free function that returns a string, if a specific environment variable has not been set. The function looks like this:
namespace
{
std::string getNameString()
{
char * datastr_ = getenv(MY_ENVAR.c_str());
if (datastr_)
return std::string(datastr_);
return DEFAULT_NAME;
}
};
I then carry out the following steps (in the order given below)
- I have edited my /etc/environment and added the appropriate environment variable
- I confirm that the variable has been set by typing printenv on the console
- I stop and then start the apache daemon
When I debug my application, I find that the environment variable has not been set. I suspect that the environment under which the fastcgi application is running may different from the environment 'normal' applications run under.
Does anyone know how to retrieve environment variable in a fastcgi app?