Changes to the PHP.ini configuration file can be a big problem for a PHP developer. The problem is that the location of the PHP.ini configuration file varies depending on the operating system and environment, and it may take some time to find out where it is located.
In this article we will see where the PHP.ini configuration file is located:
- Linux distributions
- Windows operating system
- Local servers
- Live server
What is a PHP.ini file?
PHP.ini is the default configuration file used to run applications that need PHP. Here we report (and store) changes and check variables such as file size and resource limits.
Method 1: Create a script to display the location of the PHP.ini file
Whether the file is running on a live server or on a local host, the new file creation method is one of the most popular and proven ways to find a PHP.ini file.
First create a new file with the .php extension (e.g. phpinfo.php) in the root directory of the document with the following line of code :
Save the file and upload it to your root folder in HTML.
Download the file to your favorite browser by going to https://website.com/phpinfo.php.
For example, a complete list of all your PHP information is displayed on the web page. B. Your version of PHP, system information, compiler, server API, etc.
Your PHP.ini file is usually found in one of the following sections:
- Path to the configuration file
- Configuration file loaded
As mentioned above, the path to the configuration file is the default path to the PHP.ini file. The section Loaded configuration file applies when your PHP installation is used as a module.
Method 2: Searching for the PHP.ini file on GoDaddy
On GoDaddy servers the PHP.ini file is usually located in /web/config/php.ini. Behind the .ini extension can be the PHP version.
You cannot open or change the PHP.ini file via 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. A new PHP.ini file can be created using a file manager or FTP in your HTML directory or on the GoDaddy servers.
Pay attention: Always load the initialization file (.ini) into the root folder of your site.
In addition, GoDaddy asks you to name your initialization file php.ini if you use PHP version 4, and your initialization file php5.ini if you use PHP version 5.
After creating the new file, execute the phpinfo.php script and you will see the path to the newly uploaded file. You can edit this file to change the PHP settings.
Method 3: Locating a PHP.ini file on Linux
There are two ways to find the PHP.ini file under Linux: the localization and grep command.
On most servers you can get information about PHP by executing the php -i command. This is similar to using the phpinfo(); function. We will use the php -i command together with grep to find information about PHP.ini.
To do this, we look in the output of PHP.ini for the text of the downloaded configuration file, and then we need to find information about PHP.ini.
To do this, execute the command:
php -i | grep Configuration file loaded
Here is my result on the server I just installed, with PHP 7.4 installed:
Configuration file loaded => /etc/php/7.4/cli/php.ini
If you don’t get results with the command, try it:
php configuration file -i | grep
Go out on the same server:
Configuration file (php.ini) Path => /etc/php/7.4/cli
Configuration file loaded => /etc/php/7.4/cli/php.ini
You can use this command if you have already installed and updated mlocate. If it is not installed, run the following command to install it:
sudo apt update & sudo apt install mlocate
mlocate is a more secure version of the localization program under Linux. Only the files available to the user are displayed. In other words, it offers a higher speed than the search function by searching a prepared database file instead of the file system.
After installing mlocate, run the following command to locate the PHP.ini configuration file:
You will see a list of PHP.ini files. Change one of them, restart the web server and check if the required changes have been made.
Method 4: Locating a PHP.ini file on Windows
On Windows you can find the PHP.ini file by executing the following command:
C:> php -i | findstr /:c Configuration file loaded
The teams get a result comparable to the following:
Configuration file loaded => /etc/php/7.2/cli/php.ini
There are three types of configuration files you need to know:
- Nginx or Apache with PHP-FPM
The following configuration files are available on Windows and Linux servers.
Pay attention: In the following examples we have replaced part of the PHP version number with X. When you place PHP in your environment, replace 7.X with the current version of PHP on your machine, such as PHP 7.0, PHP 7.1, PHP 7.3, PHP 7.4, etc.
The first PHP.ini file is for the PHP CLI program. Changes in the following configuration file only affect PHP when it is executed in the terminal. This does not affect the performance of the web server. This configuration file can be found in /etc/php/7.X/cli/php.ini.
/etc/php/7.X/apache/php.ini is the configuration file used by the APACHE plugins. This is the file you edit to make changes to the PHP.ini configuration file when using the APACHE web server.
Nginx or Apache with RHP-FPM
/etc/php/7.X/fpm/php.ini – FastCGI compatible packaging for PHP manipulation. You must edit this file if you are using a Nginx or APACHE server with PHP FPM.
Method 5: Searching for PHP.ini file on local server
On the local server, the location of the PHP.ini file depends on the server environment used. We will look at the most popular local server environments in PHP, such as LAMPP and WAMP.
The PHP.ini file is easy to find on the WAMP server. Find the WAMP server icon and go to PHP -> PHP.ini.
XAMPP is a little complicated. Démarrez the installation of XAMPP et cliquez avec le bouton droit de souris sur le bouton Config (comme pour le module APACHE). You can find the PHP.ini file in the drop-down menu.
Method 6: Searching for a PHP.ini file on the live server
The location of the PHP.ini file usually depends on your service provider.
In this section we will look for a common way to search most Livery servers. GoDaddy was a special occasion, so we’ve already discussed it. The PHP.ini file is usually located in the wp-admin directory.
To find the PHP.ini file in cPanel, open your file manager and navigate to the root directory. The configuration file can be found somewhere below. Make sure the Show hidden files check box is selected.
The root folder is the top-level folder, one level above your main public_html folder.
Method 7: Finding the PHP.ini file on shared hosting
Unfortunately you cannot open or change the PHP.ini file on shared hosting. You can make the required changes to your .htaccess file in the following template:
Here the php value is kept constant and the name is that of the PHP property you want to change. The same goes for the costs. For example, the following line changes the maximum size of the downloaded file to 10 MB :
php_value uplaod_max_filesize 10M
Restart of the web server after changes
After making the changes (at least one change) you must restart the server. Otherwise the changes will not be made.
Under Linux, run the following command to restart:
On the WAMP server, go to the server icon in the toolbar and select Restart all services.
On the XAMPP server, go to the main toolbar and click the Stop button corresponding to the APACHE module, then click the Start button again.
Route to be followed
PHP.ini is one of the most important configuration files on your server. We have tried to describe the location of the PHP.ini file in the most common server environments and systems. We will add more solutions later!
If your issue is still unresolved, please leave a comment and we will find a solution and add it in an updated article.
create php.ini file,php config file best practice,loaded configuration file (none),database config file in php,phprc,change configuration file php.ini path linux,php.ini location wordpress,php.ini file location in cpanel,ubuntu find php ini location,ubuntu get php ini,ubuntu localhost php ini,php.ini file location in xampp,php.ini file download,php.ini file location in wamp,loaded configuration file (none) windows,php code is executed on,configuration file (php.ini) path no value,configuration file (php.ini) path c /windows,What is php.ini?It is a file that defines the work of all programs which demand PHP. It contains default configurations and controls such important things as resource limits and upload size.Why could you need to find the php.ini?As was previously said – it contains very important configurations for the apps that work on PHP. If you want to change some of them – you will need phph.ini.,It is a file that defines the work of all programs which demand PHP. It contains default configurations and controls such important things as resource limits and upload size.,As was previously said – it contains very important configurations for the apps that work on PHP. If you want to change some of them – you will need phph.ini.,testing installation in php,write down three features of php,basic php syntax in hindi,explain php.ini file,php ini file location in xampp windows,php ini text,loaded configuration file (none windows),loaded configuration file: (none mac),restart php,php.ini file location wordpress,php.ini location windows,php.ini file location ubuntu,php.ini location mac,php.ini location centos