简体   繁体   English

更改 php.ini 中的值在 Nginx 中不生效

[英]Changing values in `php.ini` not taking effect in Nginx

I am using Easyengine for a WordPress site, and I need to upload a large file to the server, I know I can use FTP / SSH to do so but in the long run I need it to be done via PHP, and the current upload limit that I see is 100M when doing phpinfo(); I am using Easyengine for a WordPress site, and I need to upload a large file to the server, I know I can use FTP / SSH to do so but in the long run I need it to be done via PHP, and the current upload我在做phpinfo();时看到的限制是100M

The setup uses PHP 7 and the PHP INI file that I found is at该设置使用 PHP 7 和我发现的 PHP INI文件位于

etc/php/7.2/php.ini

I made changes to these parts:我对这些部分进行了更改:

upload_max_filesize = 2100M
post_max_size = 2100M

But even after this the upload limit is 100M as I can see on both WordPress plugin page that I am using as well as with phpinfo()但即使在此之后,上传限制也是 100M,正如我在我正在使用的 WordPress 插件页面以及phpinfo()上看到的那样

I read somewhere that Nginx needs to be restarted so I did ee site restart example.com and both Nginx and PHP were restarted still no effect. I read somewhere that Nginx needs to be restarted so I did ee site restart example.com and both Nginx and PHP were restarted still no effect.

Some articles suggested adding a rule to /etc/nginx/nginx.conf but unfortunately that path doesn't even exist, so I created that file at that path and tried but still no use.一些文章建议向/etc/nginx/nginx.conf添加一条规则,但不幸的是该路径甚至不存在,所以我在该路径上创建了该文件并尝试但仍然没有用。

To troubleshoot your issue, I'd take the following steps: 要解决您的问题,我将采取以下步骤:

  1. Check your php.ini path to check if you're editing the right one 检查您的php.ini路径,以检查您是否在编辑正确的路径

To find your php.ini , create a file called info.php or any other name in your webroot and add the following: 要找到您的php.ini ,请在您的webroot中创建一个名为info.php或任何其他名称的文件,并添加以下内容:

<?php phpinfo();

Now, go to your browser and visit: http:///test.php. 现在,转到浏览器并访问:http:///test.php。 On the resulting page search for: 在结果页面上搜索:

Configuration File (php.ini) Path

That will show you your php.ini location 那将显示您的php.ini位置

  1. Check if your PHP script isn't overwriting your settings using ini_set() 使用ini_set()检查您的PHP脚本是否未覆盖您的设置

  2. Check if your settings aren't overwritten in your pool.d fpm config file. 检查您的pool.d fpm配置文件中的设置是否未被覆盖。

    In most configurations, it's located at 在大多数配置中,它位于

    /etc/php/*/fpm/pool.d/www.conf /etc/php/*/fpm/pool.d/www.conf

  3. Make sure you restart php-fpm and nginx . 确保您重新启动php-fpmnginx

    To do so 这样做

    sudo /etc/init.d/php-fpm restart sudo /etc/init.d/nginx restart sudo /etc/init.d/php-fpm重新启动sudo /etc/init.d/nginx重新启动

I also faced this kind of issue.我也遇到过这种问题。 I was editing wrong file located at /etc/php/8.0/cli/php.ini instead of correct one.我正在编辑位于 /etc/php/8.0/cli/php.ini 的错误文件,而不是正确的文件。 Because nginx uses php-fpm version.因为 nginx 使用的是 php-fpm 版本。 So correct file was /etc/php/8.0/fpm/php.ini所以正确的文件是/etc/php/8.0/fpm/php.ini

And don't forget to kill current fpm process with sudo pkill php-fpm8.0 command.并且不要忘记使用 sudo pkill php-fpm8.0 命令杀死当前的 fpm 进程。 then type sudo service php8.0-fpm to start service normally.然后输入 sudo service php8.0-fpm 正常启动服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM