Ubuntu: Where is my PHP php.ini Configuration File?

As there are multiple versions of PHP with different sever configurations, the php.ini file could be located in several different folders.

Method 1

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 info.php.


Load this file in your browser, press CTRL + 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.

Method 2

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.0/cli/php.ini

In the above example, we can see that the PHP install is located in /etc/php/7.0


/etc/php/7.0/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.0/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.0/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.

Older Versions

For versions of Ubuntu lower than 16.04, /etc/php/5.6/,/etc/php/7.0/,/etc/php/7.1/, and so on, are replaced by /etc/php5/ and so on. Otherwise, these paths remain accurate.

Let me know in the comments if this helped. Follow me @DevAnswers or buy me a beer 🍺


Your email address will not be published. Required fields are marked *

We use Markdown to style comments, like on Github and Reddit.
To do a line break, type two spaces after the sentence.
You can add inline code by wrapping it in backticks: `code here`

    To do an entire block of code  
    type four spaces before the line
    and it will appear in a block like this.
    <-- four empty spaces