如何检查 Apache 在哪里寻找 php.ini 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1724511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:37:36  来源:igfitidea点击:

How to check where Apache is looking for a php.ini file?

apachephp

提问by Andrew

I have a feeling that Apache is using a different php.ini file that the one I am editing. I make a change in my php.ini file, restart Apache, and the change doesn't take affect. So I don't know what to do anymore.

我有一种感觉,Apache 正在使用与我正在编辑的文件不同的 php.ini 文件。我在我的 php.ini 文件中进行了更改,重新启动 Apache,但更改没有生效。所以我不知道该怎么办了。

Any ideas?

有任何想法吗?

Update: Found out it's using the right php.ini file...but I still don't know what to do!

更新:发现它使用了正确的 php.ini 文件...但我仍然不知道该怎么做!

回答by Sean

To find the file that's being run by PHP, create a phpinfo file (just <?php phpinfo();?>) and look for the 'Configuration File (php.ini) Path' directive.

要查找由 PHP 运行的文件,请创建一个 phpinfo 文件(仅<?php phpinfo();?>)并查找“配置文件 (php.ini) 路径”指令。

回答by Rob

The output from phpinfo()will contain this. When using PHP as an Apache module, it can be configured using PHPIniDirin httpd.conf(or similar).

的输出phpinfo()将包含此内容。使用 PHP 作为 Apache 模块时,可以使用PHPIniDirin httpd.conf(或类似方法)进行配置。

回答by Zak

from the command line, run

从命令行,运行

php -i |grep "php.ini" 

This will describe the location php is loading its ini file from. You can reconfigure the php.ini location by recompiling php.

这将描述 php 从中加载其 ini 文件的位置。您可以通过重新编译 php 来重新配置 php.ini 位置。

回答by Tadej

To get the php.ini file which is being used by Apache you will probably have to add phpinfo()into a .php file and open it in the browser. As php -r "phpinfo();" | grep php.iniwill outout the same as php --iniwould. Which php.ini is used for the CLI.

要获取 Apache 正在使用的 php.ini 文件,您可能必须将其添加phpinfo()到 .php 文件中并在浏览器中打开它。As php -r "phpinfo();" | grep php.iniwill outout 一样php --ini会。哪个 php.ini 用于 CLI。

回答by t0mm13b

Question for you, what platform are you running on unix or windows? If it is unix based, check if your php.ini is residing in the same directory as /etc/httpd. Again, installation of apache can vary so check...or issue the command "find / -name php.ini -print" (without quotes) to see which one is it you are using

问你,你在 unix 或 windows 上运行什么平台? 如果它是基于 unix 的,请检查您的 php.ini 是否与 /etc/httpd 位于同一目录中。同样,apache 的安装可能会有所不同,因此请检查...或发出命令“find / -name php.ini -print”(不带引号)以查看您使用的是哪个

Ok. Since you said you have found the correct php.ini, sounds like something is missing when you edited the php.ini and reloaded apache. Look in the log directory /var/log/httpd for error_log and check to see if there was errors...that would be a start!

好的。既然你说你找到了正确的 php.ini,那么当你编辑 php.ini 并重新加载 apache 时,听起来好像缺少一些东西。在日志目录 /var/log/httpd 中查找 error_log 并检查是否有错误......这将是一个开始!