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

Set PHP config Variables (like ini_set) with .htaccess

Point all requests to one PHP file

How to use subdomains as parameters in your routes (or in your web.php file)

How does PHP compare objects?

How to remove .php from the end of URLs with .htaccess

How to check if a string contains a certain substring?

How to block IPv6 IP addresses in .htaccess

How to split a string into an array, in JS

How to check if two strings are anagrams in PHP?

How to use Anonymous classes in PHP 7?