找到正确的 php.ini 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19335675/
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
Find the correct php.ini file
提问by Michael
I am currently trying to locate the correct php.ini file to edit it and restart apache so the changes will take place and I'm stumped.
我目前正在尝试找到正确的 php.ini 文件来编辑它并重新启动 apache,这样更改就会发生,我很难过。
What I have done...
我做了什么...
I have found three different php.ini files (no idea why there are three) this is how I found the files sudo find / -name php.ini It resulted in the following....
我发现了三个不同的 php.ini 文件(不知道为什么有三个)这就是我找到文件的方式 sudo find / -name php.ini 结果如下....
/etc/php5/cli/php.ini
/etc/php5/apache2/php.ini
/etc/php5/cgi/php.ini
I also did....
我也做过....
sudo php -i | grep 'Configuration File'
This showed....
这表明....
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
I changed all of them (just to be sure) to the settings I wanted.
我将所有这些(只是为了确定)更改为我想要的设置。
I restarted apache using
我使用重新启动了apache
sudo service apache2 restart
The results...
结果...
* Restarting web server apache2
I reloaded the page and it showed that the php.ini file was not updated.
我重新加载了页面,它显示 php.ini 文件没有更新。
I know this becuase I used
我知道这是因为我用过
echo ini_get('post_max_size');
Which was suppose to be changed to 20M but was still only 2M
本来应该改成20M的,结果还是只有2M
I tried rebooting my computer thinking maybe that would legit stop the apache server and reload the php.ini file with the correct setting, but alas that attempt also failed.
我尝试重新启动我的计算机,认为这可能会合法地停止 apache 服务器并使用正确的设置重新加载 php.ini 文件,但可惜这种尝试也失败了。
Is there any chance there could be another php.ini file that could be interfering? I'm at a loss and would love some help.
是否有可能存在另一个可能干扰的 php.ini 文件?我不知所措,希望得到一些帮助。
Any and all help is very appreciated!
非常感谢任何和所有帮助!
UPDATE
A better, more helpful for other users answer can be found here:
https://askubuntu.com/questions/356968/find-the-correct-php-ini-file?answertab=votes#tab-top
更新
可以在此处找到对其他用户更好、更有用的答案:https:
//askubuntu.com/questions/356968/find-the-correct-php-ini-file?answertab=votes#tab-top
采纳答案by Michael
The answer to this was very simple. Somewhere in my php.ini file I had a syntax error (or an error of some kind).
这个问题的答案非常简单。在我的 php.ini 文件的某个地方,我有一个语法错误(或某种错误)。
To fix this I downloaded the latest php.ini file from http://git.php.net/?p=php-src.git;a=blob_plain;f=php.ini-production;hb=HEADand then changed the values for upload_max_filesize and post_max_size, restarted apache, reloaded my php_info() and everything is working as expected!
为了解决这个问题,我从http://git.php.net/?p=php-src.git;a=blob_plain;f=php.ini-production;hb=HEAD下载了最新的 php.ini 文件,然后更改了upload_max_filesize 和 post_max_size 的值,重新启动 apache,重新加载我的 php_info() 并且一切都按预期工作!
Thank you to anyone that tried to help! Much appreciated!
感谢任何试图提供帮助的人!非常感激!
回答by srain
As apache call php by mod_php
, the configuration info is not the same with that in command line:
由于 apache 调用 php by mod_php
,配置信息与命令行中的配置信息不同:
create a file named index.php
at the root directory, with the code below in it:
index.php
在根目录下创建一个名为的文件,其中包含以下代码:
<?php
phpinfo();
then open it in your browser: /index.php
.
然后在浏览器中打开它:/index.php
。
Then you will see all the configuration info.
然后你会看到所有的配置信息。
回答by Bryan
create a php file and put the following code in it
创建一个php文件并将以下代码放入其中
phpinfo();
open the file in your browser and find loaded configuration file. presto.
在浏览器中打开该文件并找到加载的配置文件。急速。