One way to find out exactly which
php.ini file your web sever is using is by creating a new PHP file in document root called
Load this file in your browser, press
F and search for “Loaded Configuration File”. You should see something like
This will tell you the exact location of the php.ini file you want to edit.
Run this command to locate the
PHP.ini configuration file.
php -i | grep "Loaded Configuration File"
The result should be something like this.
Loaded Configuration File => /etc/php/7.2/cli/php.ini
In the above example, we can see that the PHP install is located in
/etc/php/7.2/cli/php.ini is for the CLI PHP program. Changes to this config file will only affect PHP as it runs in the terminal – it will NOT affect the web server.
/etc/php/7.2/apache2/php.ini is for the PHP plugin used by Apache. This is the one you need to edit if you are using the Apache web server.
/etc/php/7.2/fpm/php.ini is a fastcgi-compatible ‘wrapper’ for PHP processing. This is the one you need to edit if you’re using the Nginx web server.
For versions of Ubuntu lower than 16.04,
/etc/php/7.1/, and so on, are replaced by
/etc/php5/ and so on. Otherwise, these paths remain accurate.