Edit php.ini nginx on Ubuntu 18.04 to increase max_input_vars

August 22, 2019 287 views
Nginx Ubuntu 18.04

Hello,
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.
Thanks.

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 (http://www.example.com/info.php) 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:

/etc/php/7.2/apache2/php.ini

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: https://www.youtube.com/watch?v=u4BnhVQUK-4&t=1200s
    After that installed the ssl certificate using certbotfollowing the video https://www.youtube.com/watch?v=GEId4NuK6HI&t=66s

    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 easyengine.io - 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:

https://community.easyengine.io/t/unable-to-edit-php-ini-file/11543

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! :)

  • Went trough those topics and couldn’t find it either.
    I have updated to php7.2 on the exsiting php5 version of the tutorial.

    I don’t have the path /opt/easyengine/sites/yourdomain.com/config/php/php/conf.d

    Could it be using the comand vim to do Changes in Nginx Config as mentioned in https://easyengine.io/tutorials/php/increase-script-execution-time/ ?

    vim /etc/nginx/sites-available/example.com
    

    I’m lost :(

    • Could it be a bad installation of php?
      Because I can’t find the php-fqm in the version I’ve installed 7.2

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:
https://marketplace.digitalocean.com/apps/wordpress

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

Have another answer? Share your knowledge.