Where is the PHP.ini Configuration File Located?

Where is the PHP.ini Configuration File Located (1)
This post includes affiliate links, for which we may earn a commission at no extra cost to you should you make a purchase using our links. As an Amazon Associate, we can earn from qualifying purchases. Learn more.

For a PHP developer, making changes in the PHP.ini config file can be quite a problem. The issue is that the location of the PHP.ini config file is different depending on the operating system and environment, and it can take a bit of time to figure out its location.

In this article, we’ll discuss where the PHP.ini config file is located in:

  • Linux distributions
  • Windows OS
  • Local servers
  • Live server
  • Shared hosting

What is the PHP.ini File?

PHP.ini is the default configuration file used to run applications that require PHP. It’s where we declare (and store) the changes and control variables such as the file size, and resource limit.

Method 1: Create a Script to Display the Location of the PHP.ini File

Whether you’re running the file on the live server or localhost, the method of creating a new file is one of the most popular and proven ways to find the PHP.ini file.

To begin, create a new file in your document root with a .php extension (for example phpinfo.php) with the following line of code:

<?php phpinfo(); ?>

Save and upload the file to your main HTML directory.

In your favorite browser, load the file by accessing it at https://website.com/phpinfo.php

A complete list of all your PHP information will be displayed on the web page such as your PHP version, system details, compiler, server API, etc.

Your PHP.ini file is usually located in one of the following sections:

  • Configuration File Path
  • Loaded Configuration File

As mentioned, the Configuration file path is the default one of the PHP.ini files. The Loaded Configuration File section applies when your PHP installation is used as a module.

Method 2: Finding PHP.ini File on GoDaddy

In GoDaddy servers, the PHP.ini file is usually located in /web/config/php.ini. The .ini extension might be followed by the PHP version.

You cannot access or edit your PHP.ini file using FTP or the File Manager in the control panel. To fix this, you need to create a new PHP.ini file and upload it to the HTML directory. The new PHP.ini file can be created using the file manager or FTP in your HTML directory or the GoDaddy servers.

Note: Always upload the initialization (.ini) file to the root directory of your site.

Also, on GoDaddy, if you are running PHP version 4, name your initialization file php.ini and if you are running PHP version 5, then name your initialization file php5.ini.

Once you’ve created the new file, run your phpinfo.php script and you will see the path to the file you just uploaded. You can further edit this file to make changes to your PHP settings.

Method 3: Finding PHP.ini File on Linux

There are two methods of finding the PHP.ini file on Linux, locate command and grep command.

GREP Command

In most servers, you can get information on PHP by running the php -i command. This is similar to using the phpinfo(); function. We’ll use the php -i command along with the grep utility to find info on PHP.ini.

We’ll do this by searching through the output from PHP.ini for the text Loaded Configuration File, and on that like we should find information on PHP.ini.

To do this run the following command:

php -i | grep "Loaded Configuration File"

Here is my output on a server I just deployed, with PHP 7.4 installed:

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

If you don’t get any result from running the command, then also try:

php -i | grep "Configuration File"

The output on the same server:

Configuration File (php.ini) Path => /etc/php/7.4/cli
Loaded Configuration File => /etc/php/7.4/cli/php.ini

Locate Command

You can use this command if you’ve already installed and updated the mlocate. If it isn’t installed then run the following command to install it:

sudo apt update && sudo apt install mlocate

mlocate is a more secure version of the locate utility in Linux. It only shows files accessible to the user. Simply put, it offers improved speed over the find tool by searching a pre-constructed database file rather than the file system.

Once you’ve installed the mlocate, proceed by running the following command to find the PHP.ini config file:

locate php.ini

It will give you a list of PHP.ini files. Edit one of those and re-start the web server and check if the required changes have been implemented.

Method 4: Finding PHP.ini File on Windows

In Windows, you can find the PHP.ini file by running the following command:

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

The commands will retrieve something similar to the following result:

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

There are three kinds of configuration files you should be aware of:

  • CLI
  • Apache
  • Nginx or Apache with PHP-FPM

The following config files are available on both Windows and Linux servers.

Note: In the following examples we’ve replaced part of the PHP version number with X. When locating PHP in your environment please replace 7.X with the actual PHP version on your machine, such as PHP 7.0, PHP 7.1, PHP 7.3, PHP 7.4, and so on.


The first PHP.ini file is for the PHP CLI program. Changes to the following config file will only affect PHP as it runs in the terminal. There will be no effect on the webserver. This config file is located at /etc/php/7.X/cli/php.ini.


/etc/php/7.X/apache/php.ini is the config file used by APACHE plugins. This is the file you edit to make changes in the PHP.ini config file if you’re using the APACHE web server.

Nginx or Apache with RHP-FPM

/etc/php/7.X/fpm/php.ini is the FastCGI-compatible wrapper for processing PHP. You need to edit this file if you’re using the Nginx server or APACHE with PHP-FPM.

Method 5: Finding PHP.ini File on a Local Server

In a local server, the location of the PHP.ini file depends on the server environment you’re using. We’ll cover the most popular local server environments in PHP like LAMPP and WAMP.


Finding a PHP.ini file in the WAMP server is easy. Locate the WAMP server icon and go to PHP -> PHP.ini.


XAMPP is a little complicated. Run your XAMPP installation and right-click on the Config button (in line with the APACHE module) and you’ll find the PHP.ini file in the dropdown menu.

Method 6: Finding PHP.ini File on Live server

The location of the PHP.ini file usually depends on your service provider.

In this section, we’ll cover the common way to navigate it in most liver servers. GoDaddy was a kind of special case and so we’ve already covered it. The PHP.ini file can be found typically in the wp-admin folder.


To locate the PHP.ini file in the cPanel, open your file manager, and navigate to your root directory. You’ll find the config file somewhere at the bottom. Make sure that the checkbox for show hidden files is checked.

The root directory is the top-level directory that is one level up from your main public_html directory.

Method 7: Finding PHP.ini File in Shared Hosting

Sadly, you can’t access or edit the PHP.ini file in shared hosting. What you can do is specify the required changes in your .htaccess file in the following pattern:

php_value name value

Here, php_value remains constant and the name represents the name of the PHP property you want to change. The same goes for the value too. For example, the following line will change the maximum uploaded file size to 10MB:

php_value uplaod_max_filesize 10M

Restart the Web Server after the Changes

Once you’ve made the changes (at least one change), you must restart the server. Otherwise, the changes will not be implemented.

On Linux, run the following command to restart:

/etc/init.d/httpd restart

On the WAMP server, go to the server icon in the toolbar and choose ‘Restart all services’.

On the XAMPP server, go to the main dashboard and click the stop button in line with the APACHE module and then click the start button again.


PHP.ini is one of the most important config files on your server. We’ve tried to cover the location of the PHP.ini file in most of the common server environments and systems. We’ll add more solutions later on!

If your issue is still unresolved, please leave a comment and we’ll find and add a solution in the updated article.

Leave a Reply

Your email address will not be published.

Related Posts