Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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();

The setup uses PHP 7 and the PHP INI file that I found is at

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()

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.

like image 436
Deepak Kamat Avatar asked Sep 07 '25 17:09

Deepak Kamat


2 Answers

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

To find your php.ini, create a file called info.php or any other name in your webroot and add the following:

<?php phpinfo();

Now, go to your browser and visit: http:///test.php. On the resulting page search for:

Configuration File (php.ini) Path

That will show you your php.ini location

  1. Check if your PHP script isn't overwriting your settings using ini_set()

  2. Check if your settings aren't overwritten in your pool.d fpm config file.

    In most configurations, it's located at

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

  3. Make sure you restart php-fpm and nginx.

    To do so

    sudo /etc/init.d/php-fpm restart sudo /etc/init.d/nginx restart

like image 90
Peter Avatar answered Sep 10 '25 01:09

Peter


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. Because nginx uses php-fpm version. So correct file was /etc/php/8.0/fpm/php.ini

And don't forget to kill current fpm process with sudo pkill php-fpm8.0 command. then type sudo service php8.0-fpm to start service normally.

like image 26
Магнайбаяр Ганзориг Avatar answered Sep 10 '25 01:09

Магнайбаяр Ганзориг