Find PHP Configuration File php.ini Location

Find PHP Configuration File php.ini Location

The php.ini is a configuration file which is read when PHP starts up. This file contains various settings that control the behavior of PHP. The location of the php.ini file depends on operating system, server configuration, PHP version, and other factors.

This tutorial shows how to find the location of the php.ini configuration file.

In most cases there are different php.ini files that are used for web server (Apache, Nginx, etc.) and PHP CLI (Command Line Interface).

Web server

To determine which php.ini file is used for web server, create a PHP file in the document root and add the following code:

php_info.php

<?php

phpinfo();

The phpinfo function prints information about configuration of the PHP. Open a web browser and search for text "Loaded Configuration File" on a page.

Using phpinfo to find php.ini file location for web server

On Linux system, the location of the php.ini file for Apache web server can be something like:

/etc/php/8.0/apache2/php.ini

PHP CLI

To find out which php.ini file is used for PHP CLI, run the php command with -i or --info option:

php -i

It will call the phpinfo function and print results. To find the required line, we can use grep command on Linux:

php -i | grep "Loaded Configuration File"

Or findstr command on Windows:

php -i | findstr /c:"Loaded Configuration File"

On Linux system, we will get the output similar to:

Loaded Configuration File => /etc/php/8.0/cli/php.ini

The 2 Comments Found

    • Avatar
      lindevs Reply

      Hi, harga mobil
      PHP GD extension supports various image formats such as PNG, JPEG, GIF, WebP, etc. GD extension should be enabled in php.ini file in order to use imagecreatefromwebp function.

Leave a Comment

Cancel reply

Your email address will not be published.