If you’re dealing with WordPress, sooner or later you have to ask yourself this question. Although not directly connected to WordPress, php.ini is one of the most important configuration files on your server because it is responsible for configuring your PHP installation, and in such a way your WordPress site and knowing php.ini location is important.
The most frequent parameter that you might need to change is upload_max_filesize. By default it’s 2Mb, which can be quite low. Other popular ones include register_globals, safe_mode, and max_execution_time. You can also use this file to enable or disable extensions of your PHP installation.
Depending on your system and server environment there are different places and ways you can find the php.ini location.
Whether you’re working on localhost, or on a live server, the easiest and proven way to locate your php.ini file is to create a PHP file with a single line of code in it, and view the output.
<?php phpinfo(); ?>
You should see something like this:
Your php.ini file should be located either in the ‘Configuration File Path’ section, or like in my case in ‘Loaded Configuration File’ section. The first location is the default one, the second location applies in case your PHP installation is used as a module.
If in some cases creating a php file and inserting a single line of code doesn’t work for you, there are some other ways to find php.ini.
If you’re working locally, finding php.ini would depend on the server environment you’re using. Let’s go quickly through some of the most popular ones.
Left click on your WAPM server icon, then go to PHP -> php.ini. Easy? Easy.
XAMPP is a bit different beast, but also can be tamed without much difficulty. Run your XAMPP installation, right click the ‘Config’ button (in front of the Apache module) and here it is, our little guy:
If you’re on Linux, run the following command in the terminal:
php -i | grep "Loaded Configuration File"
It should output something like this:
Loaded Configuration File => /usr/local/lib/php.ini
In most cases the php.ini would be located in the ‘Loaded Configuration File’, but if it’s not there, replace the ‘Loaded Configuration File’ string with ‘Configuration File’.
The location of php.ini mostly depends on the hosting you’re using, but we’ll cover here some of the most common scenarios.
Open your file manager, and navigate to the root directory. Our little guy should be sitting at the bottom.
If you don’t know how to find your root folder, simply go one level up your main public_html directory.
Unfortunately, if you’re on a shared hosting, you cannot access your php.ini file. The workaround would be to specify the needed configuration settings in your .htaccess file in the following pattern:
php_value name value
The name here represents the name of the PHP property you need to change. The same applies to the value. For example this line changes the maximum uploaded file size to 8 Mb:
php_value upload_max_filesize 8M
If you made at least one change to php.ini file, you have to restart your server, otherwise the changes won’t apply. If you’re on Linux write the following command:
/etc/init.d/httpd restart The WAMP users have to right click on the server icon in the toolbar, and choose ‘Restart all services’.
If you’re using XAMPP, go to the main dashboard, click the ‘stop’ button in front of the ‘Apache’ module, and then click the ‘start’ button again.
As you can see, finding php.ini can be both tricky and easy at the same time. I’ve tried to cover the most common solutions and server environments, and hope this guide would help you to finally locate this file. If you know any other ways to find php.ini, feel free to share your thoughts in the comments below.
It is a file that defines the work of all programs which demand PHP. It contains default configurations and controls such important things as resource limits and upload size.
As was previously said – it contains very important configurations for the apps that work on PHP. If you want to change some of them – you will need phph.ini.
Well, first of all, it will probably be upload_max_filesize. The default value for it (2Mb) is commonly too small and website owners make it bigger. Besides that, chances are you would like to change the values of register_globals, safe_mode, and max_execution_time.
Subscribe to our newsletter and access exclusive content and offers available only to MonsterPost subscribers.