How to find out which php.ini file PHP is using?

PHP: How to find out which php.ini file PHP is using?

To find out which php.ini file (and its full file path) just run the following command:

php --ini

Which will output something like this:

$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

If you need to check from within a PHP script, you can either put this code in (if it isn't public facing) and search for 'Loaded configuration file':

  1. <?php phpinfo(); ?>

Or run:

  1. <?php var_dump(php_ini_loaded_file()); ?>

See also: php_ini_scanned_files()

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to find out which php.ini file PHP is using?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the PHP language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to select all rows for a certain month (or day, year or time), using Eloquent

How to install and use jpegoptim on Linux CentOS

How to block an IP address in .htaccess

How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

How to namespace a Laravel route group?

How to return JSON data to the user in Laravel?

What is the difference between var, let and const in Javascript?

What is the max size, by default, of GET variables?

How to undelete a soft deleted Eloquent row?

How to reverse htmlentities() / What is the opposite of htmlentities()?