Read MoreThe best VPS hosting starts from $5 per month!

How To Find The php.ini File Location In Your Server

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 where is php.ini file located 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):

<?php 
// Show all information about your php configuration
phpinfo(); 
?>

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 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 14.04) 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.

Tags:,

Leave a Reply