linux - [Solved-5 Solutions] where's my php.ini - ubuntu - red hat - debian - linux server - linux pc



Linux - Problem :

How to Find the Location of Your php.ini File ?

Linux - Solution 1:

Best way to find this is: create a php file and add the following code:

<?php phpinfo(); ?>
click below button to copy the code. By - Linux tutorial - team

and open it in browser, it will show the file which is actually being read!

Linux - Solution 2:

On the command line execute:

php --ini
click below button to copy the code. By - Linux tutorial - team

You will get something like:

Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_sqlite.ini,
/etc/php5/cli/conf.d/sqlite.ini,
/etc/php5/cli/conf.d/sqlite3.ini,
/etc/php5/cli/conf.d/xdebug.ini,
click below button to copy the code. By - Linux tutorial - team

That's from your local dev-machine. However, the second line is the interesting one. If there is nothing mentioned, have a look at the first one. That is the path, where PHP looks for the php.ini

You can grep the same information using phpinfo() in a script and call it with a browser. Its mentioned in the first block of the output. php -i does the same for the command line, but its quite uncomfortable.

Linux - Solution 3:

php -i | grep 'php.ini'
click below button to copy the code. By - Linux tutorial - team

You should see something like:

Loaded Configuration File => /usr/local/lib/php.ini
click below button to copy the code. By - Linux tutorial - team

Linux - Solution 4:

In command window type

php --ini
click below button to copy the code. By - Linux tutorial - team

It will show you the path something like

Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         /usr/local/lib/php.ini
click below button to copy the code. By - Linux tutorial - team

If the above command does not work then use this

echo phpinfo();
click below button to copy the code. By - Linux tutorial - team

Linux - Solution 5:

php -r "phpinfo();" | grep php.ini
click below button to copy the code. By - Linux tutorial - team

Related Searches to - linux - linux tutorial - where's my php.ini