php.ini File Location in Ubuntu – How to Find and Edit php.ini

php.ini file location in ubuntu

What is php.ini file, why we use it. Where’s the location of php.ini file. How do i edit php.ini file using terminal. This is the most common questions asked by beginners who are either new to PHP or Linux.

php.ini File

It is a default configuration file used when your PHP application runs. When PHP starts it reads the configuration setting from php.ini file. If you have installed LAMP on Ubuntu operating system and find difficulty in locating this file, then read this post.

php.ini File Location in Ubuntu

The path of php.ini in Ubuntu is /etc/php5/apache2 . Open the terminal and start typing following commands.

To view the files present in apache2 directory, type ls command. The files present in this directory (conf.d and php.ini) are displayed.

If you are not familiar with Linux commands then read my previous post on Linux Commands with Examples .

The other easiest way to locate php configuration (php.ini) file is using locate command.

Subscribe Our Tutorials

Get Latest Updates on Facebook

How to Edit php.ini File

How to open php.ini file on terminal. To edit or view the php.ini file i am using vim or vi editor.

Read more about Beginners guide for vi/vim editor.

You can directly open this file.

NOTE – Once you have done the changes in php.ini file. You need to restart the apache webserver so that the new changes get reflected.

To restart the Apache WebServer.


PHP Script to Find the Location of php.ini File

If you are working on  Windows, Ubuntu or any operating system. You can easily find the location php.ini file using simple PHP script.

Create a php file. Let’s name it inipath.php (you can choose any name with .php extension) .

Execute this file and you will get the path of php.ini file.

php.ini file location

I am using Ubuntu and the location of php.ini in Ubuntu is /etc/php5/apache2/php.ini . Similarly if you are running this script on Windows and Mac you’ll get the path as per their directory structure.


I hope this tutorial helped you to find and edit php.ini file. If you are still facing any issue you can ask your question through comments.


About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , . Bookmark the permalink.