find php.ini location

How to Find Php.ini

PHP is a popular web programming language that allows you to easily build and manage websites. PHP.ini is its configuration file that contains all settings about your PHP installation. Often you may need to find location of php.ini in your PHP installation. In this article, we will learn how to find php.ini in your website.

How to Find Php.ini

There are several ways to find php.ini. You may hear that the following command gives location of php.ini file but it does not always work.

$ php --ini
$ php -i

When you run the above command, you will see something like the following. The part in bold seems like the location of php.ini file.

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,

The above command may not always yield the actual location used by your web server, so avoid the above method.

Instead, the following approach will give you the right location of php.ini file. Add the following line to your web page and open it in a browser. For example, create an empty file test.php in your website’s root location, e.g. /var/www/html.

$ vi test.php

Add the following line to it.

<?php phpinfo(); ?>

Now restart Apache server and go to http://your_domain_or_server_ip/test.php.

You will see a page with lot of configuration information about your PHP installation. Among the various information displayed, you will also see location of PHP configuration file.

The first approach only lists the location one of the php.ini file in your system but it may not be the file used your web server. So it may happen that you modify the settings in the file location displayed in output of php –ini and it may not change anything on your website. That is why, it is important to call phpinfo() in a web page and serve it via your web browser. This way, you will get the exact file that is being used by your web server.

Also read:

How to Delete Rows from Dataframe Based on Condition
How to Iterate Over Rows in Pandas Dataframe
How to Fix SettingWithCopyWarning in Pandas
How to get Row Count of Pandas Dataframe
How to Merge Dataframes in Pandas based on Columns

Leave a Reply

Your email address will not be published.