Where is the php.ini file on a Linux/CentOS PC?

PhpLinuxCentos

Php Problem Overview


I can't find PHP.ini location on my server. I've checked all Stack Overflow answers but I can't find my php.ini location.

I have Linux, Cent OS, zPanel. Last version of PHP.

My computer: Linux Mint 15 KDE.

Php Solutions


Solution 1 - Php

In your terminal/console (only Linux, in windows you need Putty)

ssh user@ip
php -i | grep "Loaded Configuration File"

And it will show you something like this Loaded Configuration File => /etc/php.ini.

ALTERNATIVE METHOD

You can make a php file on your website, which run: <?php phpinfo(); ?>, and you can see the php.ini location on the line with: "Loaded Configuration File".

Update This command gives the path right away

cli_php_ini=php -i | grep /.+/php.ini -oE  #ref. https://stackoverflow.com/a/15763333/248616
    php_ini="${cli_php_ini/cli/apache2}"   #replace cli by apache2 ref. https://stackoverflow.com/a/13210909/248616

Solution 2 - Php

You can find the path to php.ini in the output of phpinfo(). See under "Loaded Configuration File".

enter image description here

Solution 3 - Php

On most installs you can find it here:

/etc/php.ini

Solution 4 - Php

php -i |grep 'Configuration File'

Solution 5 - Php

#php -i | grep php.ini also will work too!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMM PPView Question on Stackoverflow
Solution 1 - PhpNETCreator Hosting - WebDesignView Answer on Stackoverflow
Solution 2 - PhpHein Andre GrønnestadView Answer on Stackoverflow
Solution 3 - PhpTheRealJAGView Answer on Stackoverflow
Solution 4 - PhpsrainView Answer on Stackoverflow
Solution 5 - PhpRandeepView Answer on Stackoverflow