更改 php.ini 文件后是否需要重新启动 Apache?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12892331/
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
Do I need to restart Apache after changing the php.ini file?
提问by simbro
If I make a change to a setting in the php.ini file - do I need to restart Apache in order for it to take effect?
如果我对 php.ini 文件中的设置进行了更改 - 是否需要重新启动 Apache 才能使其生效?
回答by arkascha
Depends, actually. Depends on how you use php inside that webserver:
视情况而定。取决于您在该网络服务器中使用 php 的方式:
- using php a module: you have to restart the server process
- using php as cgi backend: you do nothave to restart the server process
- using php fastcgi: not sure, actually... (restarting is on the safe side, though)
- using PHP-FPM: you have to restart the fpm server process to prevent inconsistencies
- 使用php一个模块:你必须重新启动服务器进程
- 使用PHP作为CGI后端:你没有重新启动服务器进程
- 使用 php fastcgi:不确定,实际上......(重启是安全的,不过)
- 使用 PHP-FPM:您必须重新启动 fpm 服务器进程以防止不一致
回答by Kaizoku Gambare
On Debian 8 I had to restart PHP-FPM (and Apache) The above answers are correct, but here are the commands so you won't have to googling them.
在 Debian 8 上,我必须重新启动 PHP-FPM(和 Apache) 以上答案是正确的,但这里是命令,因此您不必在谷歌上搜索它们。
Restart Apache :
重启阿帕奇:
/etc/init.d/apache2 restart
Restart php5-fpm :
重启 php5-fpm :
sudo service php5-fpm restart
回答by hakre
That depends on the SAPI you're using. If you're using PHP as an Apache module for example, you need to restart apache so that the php.inivalues take effect.
这取决于您使用的 SAPI。例如,如果您使用 PHP 作为 Apache 模块,则需要重新启动 apache 以使这些php.ini值生效。
If you're using FCGI, you need to restart the FCGI daemon for the PHP script that you want to see the values changed. Compare with
如果您正在使用 FCGI,则需要为要查看更改的值的 PHP 脚本重新启动 FCGI 守护程序。与之比较
回答by lcompare
It depends on what OS and version you are running.
这取决于您运行的操作系统和版本。
I am running Apache/2.4.29 under Ubuntu.
我在 Ubuntu 下运行 Apache/2.4.29。
PHP Version 7.2.24.
PHP 版本 7.2.24。
I restart apache with the following command and the restart is needed after modifying the php.ini file:
我用下面的命令重启apache,修改php.ini文件后需要重启:
sudo service apache2 restart

