This tutorial will teach you to Find php.ini Configuration File Location on Linux.
php.ini is a special file provided as a default configuration file for PHP. The purpose of the php.ini file is shown in the list below:
- It’s an essential configuration file that controls what a user can or cannot do with the website.
- Each time PHP is initialized, the php.ini file is read by the system.
- Sometimes you need to change the behavior of PHP at runtime, then this configuration file is used.
- All the settings related to registering global variables, uploading maximum size, displaying log errors, resource limits, the maximum time to execute a PHP script, and others are written in a file as a set of directives that helps declare changes.
- The php.ini file is the default configuration file for running applications that require PHP in Linux or other OS. It controls variables such as upload sizes, file timeouts, and resource limits.
- the php.ini file is the configuration file. It is constantly checked when the server gets started or HTTP is restarted in the module and it configures the website to know what a user can or can’t do with a website.
- It also helps with the administration of the web server easily.
Steps To Find php.ini Configuration File Location on Linux
To complete this guide, you must log in to your Linux system such as Ubuntu, Debian, RHEL, etc, and follow the steps below.
In this guide, you will learn to find your php.ini file location by using the Linux commands.
Use grep Command to Find php.ini File Location
In Linux and Unix Systems Grep, short for “global regular expression print”, is a command used in searching and matching text files contained in regular expressions. Furthermore, the command comes pre-installed in every Linux distribution.
From your Linux terminal, use the following grep command to locate the PHP.ini configuration file:
php -i | grep "Loaded Configuration File"
Example Output Loaded Configuration File => /etc/php/7.4/cli/php.ini
Or you can use the following command instead to find your php.ini file location:
php -i | grep ini
Example Output Configuration File (php.ini) Path => /etc/php/7.4/cli Loaded Configuration File => /etc/php/7.4/cli/php.ini Scan this dir for additional .ini files => /etc/php/7.4/cli/conf.d Additional .ini files parsed => /etc/php/7.4/cli/conf.d/10-opcache.ini, /etc/php/7.4/cli/conf.d/10-pdo.ini, /etc/php/7.4/cli/conf.d/20-calendar.ini, /etc/php/7.4/cli/conf.d/20-ctype.ini, /etc/php/7.4/cli/conf.d/20-exif.ini, /etc/php/7.4/cli/conf.d/20-ffi.ini, /etc/php/7.4/cli/conf.d/20-fileinfo.ini, /etc/php/7.4/cli/conf.d/20-ftp.ini, /etc/php/7.4/cli/conf.d/20-gettext.ini, ...
Use locate Command to Find php.ini File Location
The locate command is a Unix utility used for quickly finding files and directories.
If the locate command is not installed on your Linux system, use the commands below to install it:
On Centos / RHEL:
sudo yum install mlocate
On Ubuntu / Debian:
sudo apt install mlocate
When your installation is completed, you must first run “updatedb” command on the server so that locate will store all the file locations in mlocate.db.
Then, you can use the locate command to find your php.ini location file:
Example Output /etc/php/7.4/apache2/php.ini /etc/php/7.4/cli/php.ini /usr/lib/php/7.4/php.ini-development /usr/lib/php/7.4/php.ini-production /usr/lib/php/7.4/php.ini-production.cli
That’s it, you are done.
At this point, you have learned to Find php.ini Configuration File Location on Linux with grep and locate Linux Commands.
Hope you enjoy it. You may be interested in these articles on the orcacore blog:
Use AWK Command with Examples on Linux