Call to undefined function apache_getenv() CentOS Stream 9 and PHP 8.1

huangapple go评论111阅读模式
英文:

Call to undefined function apache_getenv() CentOS Stream 9 and PHP 8.1

问题

我遇到了这个错误:

调用未定义的函数apache_getenv()

看到建议只需切换到getenv(),但我不明白为什么我应该这样做,因为手册暗示它应该在PHP 8中可用。我已经按照这些说明进行了尝试,发现它未列在php.ini禁用的函数中。

我已经尝试禁用SELinux,但仍然存在同样的问题。出了什么问题?

我在一个评论中读到的一件事是,phpinfo()显示的服务器API不是Apache,而是FPM/FastCGI。但手册没有提到这个要求,所以我宁愿继续使用FPM/FastCGI,除非我需要更改它。

Call to undefined function apache_getenv() CentOS Stream 9 and PHP 8.1

对于这里出了什么问题有什么想法吗?

英文:

I get this error:

Call to undefined function apache_getenv()

I see suggestions to just switch to getenv(), but I don't see why I should have to since the manual implies it should be available for PHP 8. I have followed these instructions to find that it is not listed in the php.ini disabled functions.

I have tried with SELinux disabled, same problem. What gives?

One thing that I read in a comment is that the server API displayed by phpinfo() is not Apache, but rather FPM/FastCGI. But the manual doesn't say anything about this requirement so I'd prefer to continue to use FPM/FastCGI unless I need to change it.

Call to undefined function apache_getenv() CentOS Stream 9 and PHP 8.1

Any ideas about what is wrong here?

答案1

得分: 1

From the "Introduction" section of the Apache functions documentation:

"These functions are only available when running PHP as an Apache module."

Your server API is PHP-FPM rather than mod_php, thus the functions are unavailable. This makes sense because PHP-FPM does not integrate with Apache HTTP Server; it merely receives requests through a socket and sends a response back.

I don't know about your exact use case, but the $_SERVER superglobal array tends to be the most compatible way to fetch information about your environment.

英文:

From the "Introduction" section of the Apache functions documentation:

> These functions are only available when running PHP as an Apache module.

Your server API is PHP-FPM rather than mod_php, thus the functions are unavailable. This makes sense, because PHP-FPM does not integrate with Apache HTTP Server, it merely receives requests through a socket and sends response back.

I don't know about your exact use case, but $_SERVER superglobal array tends to be the most compatible way to fetch information about your environment.

huangapple
  • 本文由 发表于 2023年8月5日 07:01:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839515.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定