In your terminal/console (only Linux, in windows you need Putty)
ssh user@ip php -i | grep "Loaded Configuration File"And it will show you something like this Loaded Configuration File => /etc/php.ini.
ALTERNATIVE METHOD
You can make a php file on your website, which run: <?php phpinfo(); ?>, and you can see the php.ini location on the line with: "Loaded Configuration File".
Update This command gives the path right away
cli_php_ini=php -i | grep /.+/php.ini -oE #ref. //stackoverflow.com/a/15763333/248616 php_ini="${cli_php_ini/cli/apache2}" #replace cli by apache2 ref. //stackoverflow.com/a/13210909/248616This 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?
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.
First of all find the php.ini file location using command line in linux.
- Login to your server via ssh.
- Now check the installed php version using below command.
Let’s find the php.ini file using below command.
You will some output like below:
Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.iniNow you found your php.ini file located in /etc/ directory.
Get PHP information using CLI
To 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 pdoYou can also heck the php loaded module with above but you can also I check the php module using creating php.info file.
FAQs
Where 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.
What is the location of php.ini file in WordPress?
Default location of php.ini file in WordPress is wp-admin directory.
Thank you! for visiting LookLinux.
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
You may also like
About the author
Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.
Imagine you are given a server and you are asked to change its PHP settings. Also, assume that several different versions of PHP are installed on this server. What do you think is the best way to find a PHP configuration file? You will find the answer to this question below.
Method 1 (phpinfo
file):
#
One way to find out exactly which php.ini file your web sever is using is by creating a new PHP file in document root called info.php
<?php phpinfo(); ?>Load this file in your browser, press CTRL + F and search for “Loaded Configuration File”. You should see something like.
This will tell you the exact location of the php.ini file you want to edit.
Method 2 (PHP.ini & grep command) #
In Linux, run this command to locate the PHP.ini configuration file.
$ php -i | grep "Loaded Configuration File"Or better way:
$ php -i | grep iniOr in Windows Command Line:
$ php -i | findstr /c:"Loaded Configuration File"The result should be something like this.
$ Loaded Configuration File => /etc/php/7.4/cli/php.iniMethod 3 (locate command) #
Using the locate command in Linux. If it’s not already installed, run sudo apt install mlocate [On Debian/Ubuntu] and sudo yum install mlocate [On CentOS/RHEL]
$ locate php.iniYou should see a list of php.ini files here.
How install PHP extension (like Zip) on Cantos / Ubuntu / Linux