Edit php.ini nginx on Ubuntu 18.04 to increase max_input_vars

Posted August 22, 2019 35.4k views
NginxUbuntu 18.04

I need to increase the PHP Max. Input Vars and PHP Max. Input Time to install a theme in wordpress.

I’m using nginx on ubuntu 18.04 with easyengine commands.
The php version is 7.2 and the path for php.ini is etc/php/7.2/cli/php.ini

In putty used
sudo nano /etc/php/7.2/cli/php.ini
and after change maximputvars and maximputtime restarted nginx with
sudo service nginx restart

Can someone help here? I’ve seen others with fpm instead of cli paths. I’m a noob and I’m stuck.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
5 answers

You are close - as you mentioned, you are probably editing the wrong php.ini file. In this case, “cli” stands for “command line interface” so when you SSH into your droplet and run a php command, it will reference that .ini for its settings.

What you need is the .ini file that nginx is referencing. Do you have a /etc/php/7.2/fpm/php.ini file? If so, that’s likely the one you need to edit.

After editing it, you’ll probably only need to restart the php fpm service, not nginx (although it doesn’t hurt to do that too).

If you don’t have that file and cannot find the php.ini on the file system, you might be able to see it on a wordpress admin system information page (or plugin) or you could make your own temporary php script with phpinfo(); in it - that will display location of the current .ini file in use.

good luck and let us know how it is going

  • I keep trying finding is the php.ini file used.

    Tried the script phpinfo(); but when accessing the ( 404 Not Found nginx page shows.

    After used the command php --ini

    Configuration File (php.ini) Path: /etc/php/7.2/cli

    and the php -i

    Loaded Configuration File => /etc/php/7.2/cli/php.ini

    I’ve changed the php.ini on cli path, will it affect my install later?
    Also, I don’t have a /etc/php/7.2/fpm/php.ini file.
    Is there another way or command instead installing a wordpress plugin?

So, when you run php on the commandline its only going to report back information about the cli version of PHP. The version that is used by the website is a different file and ini.

Let’s back up a moment… did you create a 1-Click Wordpress droplet via the DigitalOcean marketplace? Or did you create a LEMP droplet and then manually install Wordpress on there? I ask because the 1-click uses Apache, not Nginx so some instructions will be different.

If you did the 1-click or are not sure, please see if you have this file:


If you do have this file, make your changes and then restart apache2:

sudo service apache2 restart

If you do not have this file, try the following command - it will list all the directories and then you can copy / paste it here so we can see what is available:

Run this command:

ls -lah /etc/php/7.2

You should see something like this:

# ls -lah /etc/php/7.2/
total 20K
drwxr-xr-x 5 root root 4.0K Aug 16 13:50 .
drwxr-xr-x 3 root root 4.0K Aug 16 13:50 ..
drwxr-xr-x 3 root root 4.0K Aug 16 13:51 apache2
drwxr-xr-x 3 root root 4.0K Aug 16 13:51 cli
drwxr-xr-x 2 root root 4.0K Aug 16 13:51 mods-available

If you are not using apache2, please share the results of the ls command so we can see what other php.ini files might be in use.

Thanks and good luck!

  • I’ve created a droplet of Ubuntu 18.04 and followed a tutorial in youtube and intalled wp using easyengine commands.
    Not sure if I can share the video link:
    After that installed the ssl certificate using certbotfollowing the video

    Here is the results with the command ls -lah /etc/php/7.2

     ls -lah /etc/php/7.2
    total 20K
    drwxr-xr-x 5 root root 4.0K Aug 22 14:10 .
    drwxr-xr-x 8 root root 4.0K Aug 22 13:12 ..
    drwxr-xr-x 3 root root 4.0K Aug 22 14:10 apache2
    drwxr-xr-x 3 root root 4.0K Aug 22 18:11 cli
    drwxr-xr-x 2 root root 4.0K Aug 22 14:10 mods-available

    I have the file /etc/php/7.2/apache2/php.ini

    This is the file I have to change?
    Did I do something wrong or my setup is wrong in some step?

    Thanks for the help.

Sorry, I’m not familiar with - it looks like it installs wordpress on a docker container on your droplet? If so, the container configuration files will be separate from your droplet’s configuration, eg, it can run nginx and php inside the container and the conf and ini files are also inside the container.

If you followed the video tutorial including the easyengine or ee steps then you will need to edit the php.ini file on the container.

An example of someone else trying to do the same can be found here on the easyengine support forum:

It’s a combination of docker commands and the normal commands you’d use to edit a text file.

Check those out and let us know if you need help progressing further! :)

Sometimes it is easier to start over … have you looked at the 1-Click WordPress option? When you create a droplet, you can select the “Marketplace” tab next to “Distributions” and “Container Distributions”.

That will install wordpress, php7.2 and apache2 - is there any specific reason you need the features of easyengine or nginx? If not, it might be worth starting with a good install. After you create the 1-Click droplet and SSH in the first time, it will walk you through setting it up.

More info here:

I was trying to do it manually to learn on the way.
Will opt the 1-click install this time. :)
Thanks for the help

  • Just in case someone is still having a hard time doing this… Follow these steps…

    • In SSH, run this php -i | grep php.ini It will then show these results…

    Configuration File (php.ini) Path => /etc/php/7.4/cli
    Loaded Configuration File => /etc/php/7.4/cli/php.ini

    • Instead of using /cli/, replace it with /fpm/
      so run nano /etc/php/7.4/fpm/php.ini to edit the file
      update upload_max_filesize as desired then save

    • Restart by running service php7.4-fpm restart

    If in case your PHP version is 7.2 just replace 7.4 to 7.2

    Also incase you are not sure of your php.ini locations you can run locate php.ini and this is the result

    /etc/php/7.4/fpm/php.ini <- use this