0

I’m hoping to get some help with an Apache/PHP 8 issue I’m encountering. Since upgrading to PHP 8 on my LAMP server, my logs have been outputting the following error:

PHP Fatal error:  Uncaught Error: Call to undefined function apache_getenv() ...

I've done a quick debug with var_dump(is_callable('apache_getenv')) and the value returns as bool(false).

I've attempted:

  • Disabling PHP 8, restarting Apache, re-enabling PHP 8, and restarting Apache again
  • Restarting my whole Linux system, system (for the heck of it)

Nothing seems to work and I'm a bit stumped on how to fix this. My application depends on a few environmental variables set in my site .conf file, so apache_getenv is important.

Is this just the case of a missing module or a bad install? What am I missing?

Any help would be appreciated.

For reference, my system is running Ubuntu 18.04.5

Thanks!

jaemega
  • 11
  • 4
  • How is PHP etc installed? Linux Distro, Version, Repos etc. – madflow Oct 10 '21 at 19:27
  • Have you tried use getenv()? – C. Celora Oct 10 '21 at 19:30
  • @madflow I'd installed PHP using `apt install php8.0 libapache2-mod-php8.0` (including the obligatory `php8.0-fpm`) on Ubuntu 18.04.5 @C.Celora Wow! I don't know why I hadn't thought to check `getenv()`. That did the trick for surfacing the ENV values I need. Thank you! – jaemega Oct 10 '21 at 20:20
  • Please check your **Server API** in `phpinfo()` . Is it **Apache 2.0 Handler** ? – Rain Oct 12 '21 at 02:56
  • @Rain Yup, the SAPI is using `apache2handler`. – jaemega Oct 19 '21 at 13:29

1 Answers1

1

UPDATE: Based on @C. Celora's recommendation above, getenv() seemed to solve my overarching problem of not being able to get my environmental variables via apache_getenv(). Thank you!

I still haven't figured out why apache_getenv doesn't work on my PHP 8 install, but that's no longer a blocker for me.

jaemega
  • 11
  • 4