英文:
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,除非我需要更改它。
对于这里出了什么问题有什么想法吗?
英文:
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.
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论