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 fix the MySQL related "Specified key was too long error" error in Laravel

How to eager load multiple levels of relationships in Eloquent?

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

How could you include a custom function for every single time PHP runs?

How to set environmental variables in your .htaccess file

How to find an item by Primary Key in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

How to query mysql using PDO in PHP?

What is the spaceship operator (<=>) in PHP?

How to group a SQL statement in brackets/parenthesis

How to create random numbers in JS?