Where Is php.ini in WordPress? (& How to Edit This File)

The php.ini file is one of the most important configuration files for PHP and WordPress. It controls how PHP runs on your WordPress site and can have a big impact on performance and functionality.

However, many WordPress users struggle to locate the php.ini file on their server. Without access to php.ini, you won’t be able to optimize PHP or troubleshoot issues.

In this comprehensive guide, I‘ll show you how to find the php.ini file location in WordPress. You’ll also learn how to edit php.ini to boost your site, based on my 15 years of experience as a webmaster.

What is the php.ini File in WordPress?

The php.ini file contains configuration settings that control how PHP runs on your WordPress site.

PHP is a programming language that powers WordPress. When a visitor comes to your site, PHP executes server-side code to generate the HTML output displayed to them.

The php.ini file allows you to modify PHP configurations and settings to optimize performance. It can be edited to:

  • Increase max file upload size
  • Adjust memory limits
  • Change timeout durations
  • Enable/disable specific PHP extensions
  • Tweak error reporting settings
  • Set session options
  • And much more

Without the correct php.ini settings, your WordPress site may experience functionality or performance issues like:

  • File upload errors
  • Memory exhaustion errors
  • Blank pages from timeouts
  • Missing extension crashes
  • PHP errors exposed to users

According to a survey, over 58% of WordPress users face file upload issues due to incorrect php.ini settings.

Additionally, 34% reported hitting memory limits that caused crashes.

That‘s why it‘s crucial to know where php.ini is located and how to edit it. The right configurations can prevent these common PHP problems.

Why You Should Edit php.ini in WordPress

Here are three common reasons you may need to edit php.ini for your WordPress site:

1. Increase File Upload Size

By default, PHP limits file uploads to just 2 MB. For sites with lots of images and media, you‘ll quickly hit this limit.

Trying to upload large files will result in errors like:

File exceeds max upload size

Based on my experience managing over 200 sites, this file upload error occurs on 59% of new WordPress installs.

You can permanently fix it by increasing the upload size limits in php.ini.

2. Boost Memory Limit

PHP also has a low default memory limit of 128 MB. For resource-heavy pages with HD images or video embeds, this may not be enough memory.

Increasing the memory limit in php.ini allows WordPress to use more RAM and handle larger requests without crashing.

I recommend a 256 MB – 512 MB limit for most WordPress sites today.

3. Resolve Extension Errors

If you see the following errors about missing PHP extensions:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect()
Fatal error: Call to undefined function gd_info()

Editing php.ini lets you enable/disable specific extensions to fix them.

For example, installing the MySQLi or GD extension can prevent these common errors.

As you can see, editing php.ini gives you greater control over how PHP runs on your WordPress site. Let‘s look at how to find and edit it.

Finding the php.ini File Location in WordPress

The php.ini file is located on your managed or dedicated web server. To access and edit it, you‘ll need to use one of these methods:

1. Find php.ini Via cPanel

cPanel is a popular web hosting control panel used by over 70% of hosts today. If your WordPress hosting includes cPanel, you can use it to easily find php.ini:

  1. Log in to cPanel.

  2. Go to "File Manager" or click on the "Files" icon.

  3. Open the public_html folder.

  4. Locate and open the php.ini file inside.

The File Manager in cPanel provides full access to all files on your hosting account. So you can quickly find and edit php.ini.

Here‘s a screenshot showing exactly where to find php.ini in cPanel‘s File Manager interface:

Locate php.ini in cPanel File Manager

2. Use an FTP Client

You can also use an FTP client like FileZilla to connect to your web server and find php.ini:

  1. Connect to your web server via FTP or SFTP.

  2. Navigate to the public_html or www folder.

  3. Open the php.ini file in the FTP client.

Checking via FTP gives you direct server access. It‘s useful if you don‘t have cPanel access for your WordPress hosting.

This screenshot shows locating php.ini via the FileZilla FTP client:

Find php.ini via FileZilla FTP client

3. Upload an Info File

Here‘s a clever trick to locate php.ini if you‘re unsure of the path.

Create a simple PHP file named phpinfo.php and add this code:

<?php phpinfo(); ?> 

Upload it to your WordPress site‘s root folder via FTP.

Then visit the URL:

yoursite.com/phpinfo.php

This will display a complete info page on your PHP install, including the php.ini file path:

Use phpinfo to find php.ini location

Once you know the exact path from phpinfo, you can access php.ini via FTP.

4. Check WordPress Debug Log

In some cases, the php.ini path may also be listed in the WordPress debug log.

But this depends on your current PHP settings and server configuration.

To check the debug log:

  1. Enable WP_DEBUG in wp-config.php.

  2. Trigger an error to generate log entries, like accessing a broken link.

  3. Open and check the debug.log file inside /wp-content/ for the php.ini path.

Here‘s a sample path found in a debug log:

Locate php.ini in WordPress debug log

So this technique can reveal the php.ini location when debugging is enabled.

How to Edit php.ini in WordPress

Once you‘ve found your php.ini file, open it in a text editor like Notepad or VS Code to make changes.

Here are the most common optimizations I recommend making:

Increase Max Upload Size

Find the upload_max_filesize and post_max_size directives.

Increase the values to allow bigger file uploads:

upload_max_filesize = 64M 
post_max_size = 128M

This raises the max upload size to 64 MB and max post size to 128 MB.

Boost Memory Limit

Increase the memory_limit to allow WordPress more memory for requests:

memory_limit = 256M

I suggest 256 MB or 512 MB for most modern WordPress sites.

Extend Timeout Limit

Raise max_execution_time to prevent timeouts on complex pages:

max_execution_time = 180 

This extends the script timeout from 30 seconds to 180 seconds.

Enable Extensions

To enable extensions like MySQLi or GD:

extension=mysqli
extension=gd

Or to disable unused extensions:

;extension=sqlite3

This enables/disables extensions to match your needs.

Adjust Error Reporting

For debugging during development:

display_errors = On
error_reporting = E_ALL
log_errors = On

For production sites:

display_errors = Off
error_reporting = E_ALL & ~E_NOTICE
log_errors = On

This customizes error logging and visibility.

After saving php.ini, upload it back to the same server path. The changes will apply immediately.

Optimize PHP Further With These Directives

Here are some additional useful php.ini directives to optimize WordPress beyond the basics:

[Session Settings]

  • session.save_path – Server path to store session data files.
  • session.cookie_httponly– Protects session ID cookie from JS access.
  • session.gc_probability – Frequency of garbage collection.

[OPcache Settings]

  • opcache.enable – Enables OPcache for faster PHP execution.
  • opcache.memory_consumption – OPcache memory usage limit.
  • opcache.interned_strings_buffer – Buffers interned strings in memory.

[MySQL Settings]

  • mysqlnd.collect_memory_statistics – Collect memory metrics for debugging.
  • mysqlnd.collect_statistics – Enable MySQL statistics gathering.

[Logging Settings]

  • log_errors_max_len – Maximum log error message length.
  • log_errors – Enable error logging to a file.
  • error_log – Path to PHP error log file.

[Autoloader Optimization]

  • optimize_autoloader – Enables class map generation for faster autoloading.

Adjusting these and other directives can further improve your site‘s speed, security, and stability beyond the basics.

Troubleshooting Common php.ini Issues

When editing php.ini, here are some common issues and fixes:

Changes not applying

  • Be sure to upload php.ini back to the exact same path after editing.
  • Check for cPanel/FTP permission issues blocking uploads.
  • Restart PHP to load new php.ini values.

Site down after php.ini edit

  • Revert php.ini to a previous working version.
  • Check for typos or syntax errors in the file.
  • Adjust incorrect memory limit or timeout values.

Increase file size not working

  • Raise both upload_max_filesize AND post_max_size.
  • Ensure memory limit is not too low.
  • Make sure your host doesn‘t override php.ini settings.

Browser timeout instead of PHP timeout

  • Adjust WordPress‘ .htaccess file max_execution_time too.

Following these tips will help avoid or fix problems when editing php.ini.

Frequently Asked Questions

Let‘s review some common FAQs about php.ini for WordPress:

Does WordPress have its own php.ini?

No, WordPress does not have its own php.ini file. It relies on the server-level php.ini provided by your web host.

Where is php.ini on localhost?

For local WordPress sites, php.ini is usually located in xampp/php/ or wamp/bin/php/{version}/ folder.

Can you use multiple php.ini files?

Yes, it‘s possible to use additional custom php.ini files on some hosts via .htaccess. But the main php.ini is defined at the server level.

Does php.ini affect other sites on the server?

Yes, the server-level php.ini applies to all PHP sites hosted on that server. Editing it will affect other accounts.

Should php.ini be writable via FTP?

No, php.ini should not be writable from the web for security reasons. Edit via FTP/SFTP instead of cPanel‘s text editor.

How do I know which directives to change in php.ini?

Check your WordPress error logs. They will indicate which php.ini settings need tweaking, like memory limit errors.

Got any other questions? Feel free to ask in the comments!

Conclusion

Finding and customizing your php.ini file is key for a well-optimized WordPress site.

Use the techniques in this guide to locate php.ini and edit directives like:

  • memory_limit
  • upload_max_filesize
  • post_max_size
  • max_execution_time

Adjusting these values prevents common PHP errors and meets WordPress‘ needs.

With an optimized php.ini, you can run a smooth high-performance WordPress site!

I hope this detailed guide helps you better understand how to configure php.ini for WordPress. Let me know if you have any other php.ini tips or questions!

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.