This article will help you to find php.ini file location. php.in file is very useful file to coustomize the PHP behaviour at runtime and it is also a configuration file. Using this you can easily administrator Apache web server. You can set the parameters like uploading director, register global variable, disable errors and many more. If you want to make a quick adjustment to php.in file but you are not sure where it is? Show
In this article we will learn how to find and edit the php.ini file using command line. If you want to edit php.ini file in Cpanel follow this tutorial edit php.ini file in Cpanel. Find php.ini File LocationFirst of all find the php.ini file location using command line in linux.
$ php --version PHP 7.4.6 (cli) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies Let’s find the php.ini file using below command. # php -i | grep php.ini You will some output like below: Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini Now you found your php.ini file located in /etc/ directory. Get PHP information using CLITo get the php information you can also use CLI . Type “-i” follow by php command. For example: # php -I # php -i | more # php -i | grep pdo You can also heck the php loaded module with above but you can also I check the php module using creating php.info file. FAQsWhere can I find php.ini file?php.in file is very useful file to coustomize the PHP behaviour at runtime and it is default configuration file for php application. You can set the parameters like uploading director, register global variable, disable errors and many more. So run the ” php -i | grep php.ini” to find the php.ini file location. How do I open php.ini file?To open php.ini file you can use any txt editor like, vim, vi, nano etc. example: vim /etc/php.ini. How do I reload php.ini file after updating?Reload the apache service simply running, systemctl httpd reload. How do I open php.ini file in Linux terminal?To open php.ini file in Linux terminal and just use vim or vi command. For example : vim /etc/php.ini. In this tutorial, we’re going to discuss php.ini—the main configuration file in PHP. From the beginner’s perspective, we’ll discuss what it’s meant for, where to locate it, and a couple of important configuration settings it provides. What Is php.ini?Whether you’re a PHP beginner or a seasoned developer, I’m sure that you’ve heard of php.ini: the most important PHP configuration file. When PHP is run, it looks for the php.ini file in some specific locations and loads it. This file allows you to configure a few important settings that you should be aware of. Quite often, you’ll find you need to tweak settings in the php.ini file. On the other hand, it’s certainly possible that you've never needed to modify php.ini. PHP can run happily with the settings provided in the default php.ini file, since PHP ships with these default recommended settings. In fact, there are no critical configuration parameters that you must set in order to run PHP. However, the php.ini file provides a couple of important settings that you want to make yourself familiar with. In fact, as a PHP developer, it’s inevitable, and you’ll encounter it sooner rather than later. Where Is php.ini?In this section, we’ll see how to find the php.ini file which is loaded when you run the PHP script. This can be tricky—the location of the php.ini file vastly varies by the environment you’re running PHP with. If you’re running Windows, you'll likely find the php.ini file within the directory of your PHP installation in the system drive. On the other hand, if you’re running another operating system, then it’s difficult to guess the exact location of the php.ini file—there are several possibilities. This is where the You can run 1 <?php
2 phpinfo(); 3 ?>
Load this file in your browser, and you should see the output of As you can see, there are two sections. The first one, Configuration File (php.ini) Path, indicates the default path of the php.ini file in your system. And the second one, Loaded Configuration File, is the path from where the php.ini file is being loaded when PHP is run. So you can edit the php.ini file indicated in the Loaded Configuration File section, and that should work in most cases. Of course, if you’re running PHP as an Apache module, you need to restart the Apache server to make sure that the changes you’ve made in the php.ini file are reflected. On the other hand, if you’re using software like WAMP or XAMPP to run your web development stack, it’s even easier to modify the php.ini file—you can directly access it via the WAMP or XAMPP UI. In the next section, we’ll explore a couple of important settings in the php.ini file. Important Settings in php.iniThe php.ini file provides a lot of configuration directives that allow you to modify various behaviors of PHP. In fact, when you open the php.ini file, you may get overwhelmed by the number of directives it provides. I'll try to group them based on their behavior, and I hope it’ll be easy for you to understand. Of course, we won’t go through each and every directive, but I’ll try to cover the most important ones. Let’s have a look at the types of directives that we’re going to discuss.
Error Handling DirectivesIn this section, we’ll go through directives that are related to error handling and are useful for debugging during development.
|