Where is the php ini file ubuntu?

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. https://stackoverflow.com/a/15763333/248616
    php_ini="${cli_php_ini/cli/apache2}"   #replace cli by apache2 ref. https://stackoverflow.com/a/13210909/248616

  • Find php.ini File Location
  • Get PHP information using CLI
  • FAQs
    • Where can I find php.ini file?
    • How do I open php.ini file?
    • How do I reload php.ini file after updating?
    • How do I open php.ini file in Linux terminal?
    • What is the location of php.ini file in WordPress?

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?

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.

  1. Login to your server via ssh.
  2. Now check the installed php version using below command.
$ 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 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 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.

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

Where is the php ini file ubuntu?

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.

Where is the php ini file ubuntu?

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 ini 

Or in Windows Command Line:

 $ php -i | findstr /c:"Loaded Configuration File"

The result should be something like this.

 $ Loaded Configuration File =&gt; /etc/php/7.4/cli/php.ini

Method 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.ini

You should see a list of php.ini files here.

How install PHP extension (like Zip) on Cantos / Ubuntu / Linux

Where is the PHP ini file located?

user. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. This file is located on your server in the /public_html folder.

How do I open PHP ini in Ubuntu terminal?

Then you simply need to type: sudo mcedit /etc/php5/cli/php. ini ..
Enter your sudo user password if asked from you..
Edit your file and use ctrl + o then press Enter for saving the file..
After that use ctrl + x for closing the file..

Where can I edit PHP ini?

Modifying the PHP..
Login to the cPanel..
Find the File Manager in File section of the cPanel. ... .
Navigate to the directory where you will either save or edit the PHP. ... .
Edit the section of the PHP. ... .
Click on SAVE CHANGES in the top right hand corner in order to save your modifications or additions to the file..