2

I recently changed the webserver environment on my production system to Apache2.4/mod_fcgid 2.3.9. On restarting Apache, I realized that my scripts depending on the PHP getenv() were broken. Checking further, I could retrieve the Windows PATH with getenv("PATH") but not several other variables set by my application installation, or even some others (e.g. PSModulePath).

Using phpinfo(), I cannot see these Windows env variables as they used be when I ran the PHP as apache module (mod_php).

I have laid out other details of my httpd.conf over at Serverfault (https://serverfault.com/questions/675736/apache-2-4-with-mod-fcgid-getenv-not-working-in-php) , where the detailed version of this question is yet unanswered.

Basically, is there a fundamental reason why php getenv(), when running on mod_fcgid, should retrieve only certain variables (maybe those originally installed with the operating system, I'm guessing), but ignore those subsequently set by other applications?

I've foraged google for close to 48 hours now, and found nothing tangible. Could anyone please be kind enough to assist with insights.

Thank you.

Community
  • 1
  • 1
Ifedi Okonkwo
  • 3,406
  • 4
  • 33
  • 45
  • I believe the vast majority of PHP installs are on some flavour of Unix/Linux, so you might struggle to get an answer to this. Sorry. Is there a reason why you have to run PHP in the Windows environment directly? Could you not run it inside a VM instead? – GordonM Mar 16 '15 at 09:16
  • @GordonM. Thanks for dropping by. I do understand that PHP and Unix are genetically much closer. The thing is: I have never really done any serious work in Unix, and again, this particular problem has never surfaced until this particular module change. AGAIN: If I am running PHP in Windows VM inside of Unix, is it not still "Windows"? – Ifedi Okonkwo Mar 16 '15 at 13:10

1 Answers1

0

To recap the problem. I had no problem (under WAMP) until I decided to change to mod_fcgid from the default of running PHP as an apache module. After this, getenv() called in my PHP code returned NULL for most Windows environment variables (even though they work perfectly as soon as I switched back to the original mod_php).

Here's what solved this issue for me, after days of stumbling. Add PassEnv for each of the missing variables that you wish to pass to PHP:

PassEnv Variable1
PassEnv Variable2
PassEnv Variable3

Then, of course, restart Apache server.

Still weird that this kind of arbitrary difference should exist, and be so poorly captured in either Apache or fcgid documentations!

Ifedi Okonkwo
  • 3,406
  • 4
  • 33
  • 45