A Complete Guide to the php.ini WordPress File

Illustration of a php.ini configuration file on a monitor with PHP and WordPress symbols

Is your WordPress site running slowly or showing strange errors? Are you experiencing performance issues on your site and want solutions?

From malware attacks to your site running out of storage space, there could be many reasons behind this. But, you’re likely here because you’ve heard that the php.ini WordPress file can help improve speed, fix upload issues, or manage memory limits.

You may have never heard of this file until today. In fact, you can go your entire life without knowing about php.ini and still run a successful WordPress site. There are several ways to make changes to your site without actually touching this file.

However, it remains an important core file, and understanding its function can deepen your site knowledge.

TL;DR

The php.ini WordPress file controls key settings for PHP, impacting how WordPress performs. It’s usually not accessible directly. However, knowing how to find and edit it can fix many WordPress site performance issues, such as memory limits and upload sizes.

The php.ini file is not a part of the WordPress file structure. But, this file is very important for a WordPress site to function. It sets rules for PHP, the language WordPress uses. If your site needs more memory or has trouble with uploads, changes in php.ini can often help. Without adjusting these settings, your site might not run as smoothly as it could.

This article will show you what the php.ini WordPress file is, where to find it, and how to edit it safely to keep your site in top shape.

Understanding the php.ini file in WordPress

The php.ini file is a configuration file for PHP. PHP is the programming language that powers WordPress. Because of this connection, php.ini directly affects how your WordPress site performs. This file controls key functions like memory limits, file upload sizes, and error logging. By doing so, it ensures your site functions well.

Although php.ini is crucial for WordPress, it’s not exclusive to it. It’s a server-level file, not a site-level one. Changes to this file affect all PHP applications on your server, not just WordPress. That’s why most web hosts either stop you from accessing the php.ini file or do not let you access it directly. Those who do, do it via a cPanel PHP editor or other proprietary control panels.

Where is the php.ini file in WordPress?

As we mentioned earlier, most web hosts don’t allow direct access to the php.ini file. Changes to this file can have widespread repercussions on your WordPress site server. Allowing everyone to edit it could lead to stability issues or security risks for your site. By restricting access, web hosts ensure that only authorized users can make changes to it. This also ensures that changes to php.ini don’t disrupt other sites on the server.

You can access the php.ini file if you are running your site on a dedicated server or if your web host lets you access it. You can find the file in the root directory, usually called public_html or www.

If you cannot find the file, use WordPress.org’s Health Check & Troubleshooting plugin. It’s a handy tool that gives you detailed information about important site files and their health, including the php.ini WordPress file.

Here’s how you can use the Health Check & Troubleshooting plugin to locate your site’s php.ini file:

  1. Install the plugin from the WordPress repository and activate it.

    Health Check and Troubleshooting
  2. Go to Tools > Site Health on your site’s wp-admin dashboard to access the plugin’s control panel.

    Site Health
  3. Click on Tools within the control panel.

  4. Open the PHP Info dropdown menu and click on View extended PHP information.

    PHP Info Dropdown
  5. In the information shown, look for Loaded Configuration File which will tell you the location of your site’s php.ini file.

    Php Config Info
Before creating a php.ini file

You can create a php.ini file in your site’s root directory and add rules to it. This file can potentially override the settings on your site server’s php.ini. So be very careful when adding rules as it could break your site. Also, remember to take a full site backup before making any changes to your site.

How do you edit the php.ini file in WordPress?

Once you have located your site’s php.ini file, here’s how you can edit it:

Edit php.ini with FTP

If you have direct access to the php.ini file, you can use an FTP client to edit it. We used the Filezilla FTP client to do so. The steps are the same as editing the wp-config.php file using FTP, except you are editing the php.ini file instead.

Edit php.ini through your web host

Some web hosts provide an interface to edit php.ini settings. For example, if your web host uses cPanel to administer your site, you can use its MultiPHP INI Editor tool. If your web host uses its own proprietary interface, then it might have some other tool for this. Regardless of which tool it is, they let you change values easily and even add custom code.

Here, we will show you how you can use cPanel’s MultiPHP INI Editor tool to modify values on your site’s php.ini file:

  1. Access your site’s cPanel and scroll down to the Software section.

  2. Click on MultiPHP INI Editor to open it.

    The cPanel Software tools list with an arrow pointing to MultiPHP INI Editor
    Open MultiPHP INI Editor from cPanel’s Software section.
  3. In the Basic Mode tab, select your site from the dropdown menu.

    MultiPHP INI Editor in Basic Mode with the location selector open
    Choose the home directory or the domain whose PHP configuration you need to edit.
  4. Ensure that the Path value shown under the dropdown menu is the correct location.

    MultiPHP INI Editor showing the selected home directory and php.ini path
    Confirm that the displayed path belongs to the intended site before changing settings.
  5. Now, you can modify the values as per your requirements.

Remember to take a full backup of your site before you make any changes here.

Ask your web host for help

If you can’t access php.ini directly or through an interface, you can ask your web host for help. Web hosts typically let you submit a support request to have them change your php.ini settings. Again, you must know what you are asking for. So read up before you ask for a change and ensure your support request is as detailed as possible.

Using .htaccess as an alternative

If none of the above methods work, you can try using the .htaccess file to override php.ini settings with PHP code. However, be aware that some web hosts either:

  • Don’t let you access your site’s .htaccess file, or
  • Don’t let .htaccess settings override php.ini settings.

If you still want to try editing .htaccess, the sample code looks like:

.htaccess syntaxAPACHE
php_value value_name value

Eg: php_value upload_max_filesize 64M

Remember, these methods can improve your site’s performance, but always proceed with caution to avoid potential issues. Don’t forget to take a backup before you start editing site files. This can help you restore your site in case of an error.

What can you change in the php.ini file in WordPress?

You can modify several important settings in the php.ini file to improve how your WordPress site functions. Here are some key changes you might consider:

Memory limit: This controls how much memory PHP scripts can use. You may increase it if your site needs more resources.

php.iniINI
memory_limit = 256M

Max execution time: This limits how long a PHP script can run before it stops.

php.iniINI
max_execution_time = 300

Error reporting: This setting defines how PHP errors are shown or logged. This can help debug your site if you are facing any issues.

php.iniINI
error_reporting = E_ALL
display_errors = Off

Upload max filesize: This determines the maximum size of files you can upload to your site. It includes everything, from themes and plugins to media files like images and videos.

php.iniINI
upload_max_filesize = 64M

Post max size: It sets the maximum size for the posts on your site and their related data. This value affects file uploads too. So ideally, you should set it to the same value as that of Upload Max Filesize.

php.iniINI
post_max_size = 64M

Max file uploads: You can set how many files can be uploaded at the same time.

php.iniINI
max_file_uploads = 20

Max input vars: It specifies how many input variables (GET/POST/COOKIE) can be accepted.

php.iniINI
max_input_vars = 1000

Extensions: You can enable or disable PHP extensions or modules, which add functionality to your site.

php.iniINI
extension = curl
Advanced settings

The Max input vars and Extensions values are quite technical for regular usage and can be skipped.

Best practices for editing the php.ini file in WordPress

When editing the php.ini file, follow these best practices to avoid issues:

  • Always backup first: Before making changes, back up your entire site. While a backup doesn’t include the php.ini file, it ensures you can restore your site if something goes wrong. If you or your host need to reset php.ini due to a mistake, having a backup will help you reclaim your site.
  • Locate the correct file: A typical WordPress installation might have multiple php.ini files. Use the Health Check & Troubleshooting (HC&T) plugin to find the right one to edit. You can also use SSH commands like which php and whereis php to locate the correct file.
  • Only change settings you understand: Stick to modifying settings you clearly understand to prevent unwanted issues. If in doubt, read up about what each value does and how it affects your site.
  • Make changes one by one and gradually: Change settings one at a time and note them down as you make them. Increase or decrease the values in gradual steps and see if it helps your site’s functioning. A steep jump, such as from 100 to 10000, can affect how your site functions, and even crash it. This cautious approach makes it easy to identify which setting might cause a problem if something goes wrong.
  • Test changes after making them: After editing, test your site to ensure everything works well. This step confirms that the changes didn’t cause issues.

Final thoughts

The php.ini file controls how WordPress operates since it controls important PHP settings. It is crucial for defining parameters like memory limits and file upload sizes. However, keep in mind that these changes impact all PHP applications on your server, including WordPress.

This is why most web hosts don’t let you access php.ini directly. But if you can access it, follow best practices to ensure your site stays stable. Always take a backup before you change anything and test your site afterward to catch any problems.

Managing php.ini settings well can make your WordPress site run better. But remember, even the smallest of changes can affect your site and other PHP applications. So be very careful when making any changes.

FAQs

The php.ini file configures PHP, the language that powers WordPress. It controls settings such as memory limits, file-upload sizes, and error reporting for WordPress and other PHP applications on the server.
It is usually in the server’s root directory, often called public_html or www. Not every host provides direct access; WordPress’s Health Check & Troubleshooting plugin can identify the loaded configuration file.
Edit the file with FTP when you have access, use your host’s PHP editor, or ask the host to make the change. Some servers allow selected overrides through .htaccess, although that approach has limitations.
No. php.ini belongs to the server’s PHP installation, not WordPress. The hosting provider determines its default settings and whether customers can view or modify them.

Anurag traded algorithms for adverbs when he switched from being a software engineer to being a writer. Editor by day, he chases F1 by night!