pheromix pheromix - 1 year ago 89
PHP Question

How to know which php.ini is used?

I search the path where the php.ini file is located in our Linux Ubuntu server, and I found many php.ini when executing the command

find / -name php.ini
. So how to know exactly from a php script web page where the php.ini is located ?

Answer Source

You can use php_ini_loaded_file()

Taken from

$inipath = php_ini_loaded_file();
if ($inipath) {
    echo 'Loaded php.ini: ' . $inipath;
} else {
    echo 'A php.ini file is not loaded';

You may also want to check php_ini_scanned_files()

Also, you should note that if you run a PHP script from CLI, it's possible that a different php.ini file will be used than if a server (ie nginx or apache) runs it.

Other options:

  • php -i|grep 'php.ini'
  • create info.php that contains <?php phpinfo(); in the webroot, and run it in your browser
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download