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
Where Is My
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
Now paste the following php scripts into the file (info.php):
<?php // show all the 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 information of current configuration of your PHP, PHP version, php.ini file location and so much more.
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
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
php -i | grep php.inito get the exact location of your
- 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.
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.