Where is PHP php.ini Configuration File Location ?

Imagine you are given a server and you are asked to change its PHP settings. Also, assume that several different versions of PHP are installed on this server. What do you think is the best way to find a PHP configuration file? You will find the answer to this question below.

Method 1 (phpinfo file):

One way to find out exactly which php.ini file your web sever is using is by creating a new PHP file in document root called info.php

[html] <?php

Load this file in your browser, press CTRL + F and search for “Loaded Configuration File”. You should see something like.

This will tell you the exact location of the php.ini file you want to edit.

Method 2 (PHP.ini & grep command) #

In Linux, run this command to locate the PHP.ini configuration file.

[html] $ php -i | grep "Loaded Configuration File" [/html]

Or better way:

[html] $ php -i | grep ini [/html]

Or in Windows Command Line:

[html] $ php -i | findstr /c:"Loaded Configuration File"[/html]

The result should be something like this.

[html] $ Loaded Configuration File =&gt; /etc/php/7.4/cli/php.ini[/html]

Method 3 (locate command) #

Using the locate command in Linux. If it’s not already installed, run sudo apt install mlocate [On Debian/Ubuntu] and sudo yum install mlocate [On CentOS/RHEL] [html] $ locate php.ini[/html]

You should see a list of php.ini files here.

Powered by BetterDocs

Leave a Reply