Php ini wordpress location

I can’t tell you how many hours I’ve wasted over the years setting upload file size limits in WordPress. Besides involving changing multiple php configuration values, it’s complicated by the fact that a typical linux install on a self-managed server will have quite a few php.ini files scattered around (e.g., several for each version of php installed, for apache, cli and fpm).

It would be great if something in the dashboard showed which php.ini file was the one being used.

Apologies if the information is already available someplace but I’ve never been able to find it.

  • This topic was modified 7 months ago by Steven Stern (sterndata).

Viewing 7 replies - 1 through 7 (of 7 total)

  • threadi

    (@threadi)

    Wordpress itself provides some information about the server under Tools > Site Health. What is usually not found there is the path to the php.ini used.

    With the plugin https://de.wordpress.org/plugins/health-check/ you can extend the output under Site Health. Then you will also find the complete phpinfo() under “Info”.

    Thread Starter MarkOlbert

    (@markolbert)

    Sorry, but I don’t see where the path information is displayed. I installed and activated the plugin, but I don’t see any newly-added sections under the info tab and all the obvious ones that I checked don’t display the path to the php.ini file.

    Where exactly is the information displayed by the plugin?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator

    WP never sees or uses the php.ini file; it’s PHP that does. You need to walk it back. IF there’s a php.ini file in the WP root, the PHP process should read it and modify its more general settings. If not, then the php.ini is likely one of the global ones, as modified by the settings in the /etc/php-fpm.d/something.conf file for that website.

    threadi

    (@threadi)

    Tools > Site Health > Info .. then click on the button “View extended php information” on the button of the page. The url should be: /wp-admin/tools.php?page=health-check&tab=phpinfo

    Thread Starter MarkOlbert

    (@markolbert)

    Thanx, @threadi! I am such an idiot — I literally didn’t notice that big, fat button…because I assumed the add-in “simply” added a new section to the accordion area.

    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.

    reliale bluehost hosting with a discount

    Depending on your system and server environment there are different places and ways you can find the php.ini location.


    What's 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.

    1. Create a file (name it however you want, in our case it’s ‘test.php’), and make sure it ends with .php extension.
    2. Put this line of code in it:
    1. Open the file via your browser. For example if you placed it into your root folder, run http://mywebsite.com/test.php.

    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.


    Other solutions

    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.

    Local server

    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.


    WAMP

    php.ini on WAMP

    Left click on your WAPM server icon, then go to PHP -> php.ini. Easy? Easy.


    XAMPP

    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:

    php.ini XAMPP


    Linux

    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’.


    Live server

    The location of php.ini mostly depends on the hosting you’re using, but we’ll cover here some of the most common scenarios.

    cPanel

    Open your file manager, and navigate to the root directory. Our little guy should be sitting at the bottom.

    php.ini cPanel

    If you don’t know how to find your root folder, simply go one level up your main public_html directory.


    Shared Hosting

    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
    

    Restart after the changes

    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.


    Final words

    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.


    FAQ

    What is php.ini?

    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.

    Why could you need to find the php.ini?

    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.

    What are the parameters that are changed the most frequently?

    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.

    How do I change PHP settings in WordPress?

    Activate the plugin through the Plugins menu in WordPress. You can now modify your php settings by going to the settings page located under wp-admin/tools. php? page=custom-php-settings.

    How do I access PHP ini?

    Your answer.
    You can get a full phpinfo() using : php -i..
    And, in there, there is the php.ini file used : $ php -i | grep 'Configuration File' Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini..
    On Windows use find instead: php -i|find/i"configuration file" Hope this is helpfull!!.

    Where is the PHP ini file in Cpanel?

    Each file exists in the /opt/cpanel/ea-php72/root/etc/php. ini file, where 72 is the PHP version number.

    How to create a PHP ini file?

    How to Manually Create a PHP..
    Log into your cPanel account..
    Open your File Manager..
    Navigate to your public_html directory..
    Create a new file..
    Name it php.ini..
    Edit the php.ini file you just created..
    Copy and Paste the default php. ini code from the copy of the default version below..
    Click Save Changes..