Where is my php.ini File Located?

php.ini is the default configuration file for web-server that runs PHP application. By editing php.ini file in your web-server you can enhance the capabilities of PHP application. For those who don’t know where is php.ini file located, Here is the instruction about this.

php.ini is a one of the most crucial file in server configuration. It controls many aspects of what you can do and what you can’t with your php based website. With php.ini file you can define the maximum size of file upload, Maximum number of file upload at a time and so much more.

If you don’t know the exact loaction of php.ini file in your server, Then you are on right address. Because, Through this blog post I will show you how to find the location of your php.ini file.

Where Is My php.ini File?

We are going to write a simple php script that will show us the exact location of our php.ini file. To do that, create a file using your notepad or preferred editor. In my case I choose the file name to be info.php. You can choose any name with .php extension.

Now paste the following php scripts into the file (info.php):

// show all the information about your php configuration

After that save the file and upload to your server root directory (public_html or htdocs or whatever your public html directory) using FTP/SFTP connection.

That’s it, Now open the file in your browser by visiting http://yourdomainname.com/info.php. You will get the information of current configuration of your PHP, PHP version, php.ini file location and so much more.

php info and current php configuration

This system works on local environment also, such as XAMPP, WAMP, Bitanami or LAMP stack (Here is How to install LAMP on Ubuntu) as well. In my case, I’m using Bitanami WordPress stack.

Different web hosting companies use different scheme for storing files, So you could find your php.ini file in different name or different location. But, Don’t worry, The simple php scripts above will help you to find it wherever it is.

Most of the shared hosting companies, host the php.ini file on restricted location, Where you can’t edit or upload a new one. In this situation, You may need to create your own php.ini file and upload to your public_html directory.

Find The php.ini File Location using Command

If you are using VPS/Cloud hosting service such as DigitalOcean, You can also find the php.ini file location using a simple command line on the terminal.

  • Open up your terminal and login to the root account or the account that has root privileges on your server
  • Run php -i | grep php.ini to get the exact location of your php.ini file.
  • Above the command will tell the PHP application to run phpinfo(); and find the actual line and then output the text format to the shell.

That’s all…

Hope the tricks in this post works on your side too and if you are encountered an error or problem, Please let me know via below the comments, I will be more than happy to assist you.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive website improvement tips and tutorials.


We'll periodically send useful information, tips & tutorials to improve your website performance, conversion optimization, SEO and design tweaks to make your website better.

Thank you for signing up!

Please check your email and click the link provided to confirm your subscription.

Powered by Rapidology
No Comments

Post a Comment