How to Change a PHP Setting on WordPress Hosting
This guide shows you how to change PHP settings on your WordPress hosting, such as increasing the memory limit, upload size, or execution time. You’ll learn the exact steps for common hosting setups—cPanel, custom admin panels, and managed WordPress hosts—plus how to do it with a plugin if you don’t have file access. You’ll need your hosting login details and, ideally, a child theme or a code editor.
What You’ll Need
- Your hosting control panel login (cPanel, Plesk, or custom)
- FTP/SFTP credentials or a file manager in your hosting panel
- A code editor (like Notepad++ or VS Code) or a text editor
- Access to your WordPress admin dashboard
- If you plan to edit theme files, a child theme (recommended)
Step-by-Step
- Identify the PHP setting you need to change. Common ones are
memory_limit,upload_max_filesize,post_max_size,max_execution_time, andmax_input_vars. Check your site’s current values by going to Tools → Site Health → Info in WordPress, then expand the “Server” section. - Check if your host allows PHP changes in the control panel. Log into your hosting account and look for a section named “PHP Settings,” “PHP Configuration,” “MultiPHP INI Editor,” or “Select PHP Version.” If you find it, you can often change values directly from there—no file editing needed.
- If using cPanel, use the MultiPHP INI Editor. In cPanel, search for “MultiPHP INI Editor” (or “PHP Settings” in some versions). Select your domain, then edit the fields like
memory_limitorupload_max_filesize. Save the changes, and the new values apply immediately. - If your host uses a custom panel, look for a “PHP” or “Developer” tab. Many managed hosts (like WP Engine, Kinsta, or Flywheel) have a settings page where you can adjust PHP values without touching files. Check your host’s documentation for the exact location.
- If no panel option exists, create a
php.inifile. Using FTP or the file manager in your hosting panel, navigate to your WordPress root folder (wherewp-config.phpis located). Create a new file namedphp.iniand add lines like:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 120
Save the file and upload it. If your host uses PHP-FPM, you may need to name it.user.iniinstead—check with your host. - Alternatively, use an
.htaccessfile (for shared hosting). Some hosts allow PHP settings via.htaccess. Add lines like:
php_value memory_limit 256M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 120
Place this in your root.htaccessfile (back it up first). This method works only if your server allowsphp_valuedirectives—many don’t. - If you can’t edit files, use a WordPress plugin. Install a plugin like “WP phpMyAdmin” or “PHP Settings” (search the plugin repository). These plugins let you change PHP values from the WordPress admin. Be cautious: some plugins may not work on managed hosts that restrict PHP settings.
- For a single site, you can also add code to
wp-config.php. Add this line before the “That’s all, stop editing!” comment:
define('WP_MEMORY_LIMIT', '256M');
This only affects the WordPress memory limit, not upload sizes or execution time. For upload sizes, you’d still need a server-level change. - After making changes, verify they took effect. Go back to Tools → Site Health → Info → Server and check the values. Or create a temporary PHP file with
<?php phpinfo(); ?>and view it in your browser, then delete it immediately. - If you edited a theme file, use a child theme. If you added code to
functions.phpof your theme, the changes will be lost when the theme updates. Create a child theme and add the code there, or use a code snippets plugin.
Common Mistakes
- Editing the wrong file. Make sure you’re editing the
php.inior.htaccessin the WordPress root, not a subfolder. - Using incorrect syntax. For
php.ini, usememory_limit = 256M(no spaces around the equals sign). For.htaccess, usephp_value memory_limit 256M(no equals sign). - Setting values too high. Setting
memory_limitto 1G on a shared server may cause errors or get your account suspended. Start with reasonable values like 256M or 512M. - Forgetting to back up. Always back up
.htaccessandwp-config.phpbefore editing. A syntax error can break your site. - Using a plugin that conflicts with your host. Some managed hosts disable PHP settings plugins. Check your host’s policy first.
Tips
- Use the hosting panel first. It’s the safest and easiest method—no file editing required.
- Test after each change. After changing a setting, load your site and run a quick check to ensure nothing is broken.
- Keep a record of original values. Write down the original settings so you can revert if needed.
- For upload size issues, also check WordPress media settings. Sometimes the limit is set by the server, but you may also need to increase
post_max_sizeto matchupload_max_filesize. - If you’re on a managed host, contact support. They can often change PHP settings for you or tell you the correct method.
Troubleshooting
- Changes don’t appear in phpinfo(). Your host may be using a different PHP version or a different configuration file. Check if you have multiple PHP versions and edit the correct one. Also, some hosts use
.user.iniinstead ofphp.ini—try that. - Site shows a 500 error after editing .htaccess. This usually means a syntax error. Restore the backup of your
.htaccessfile immediately, then try a different method (likephp.ini). - Plugin doesn’t work. Some plugins only work on certain server configurations. Check the plugin’s documentation or try a different plugin. If nothing works, contact your host.
- Changes work but revert after a while. This can happen if your host resets PHP settings periodically or if you edited a file that gets overwritten (like a theme file). Use a child theme or a must-use plugin to keep changes persistent.
- You get a “Allowed memory size exhausted” error even after increasing the limit. The error might be from a specific script that needs more memory than you set. Try increasing it further, but also check if a plugin is causing a memory leak.
Frequently Asked Questions
Can I change PHP settings on any WordPress hosting?
Most hosting providers allow you to change PHP settings, but the method varies. Shared hosts often allow .htaccess or php.ini, while managed hosts may have a settings panel or require you to contact support.
What is the safest way to change PHP settings?
Using the hosting control panel’s PHP settings editor is safest because it validates your input and applies changes correctly. File editing carries the risk of syntax errors that can break your site.
Why can’t I increase my upload size beyond a certain limit?
Your hosting provider may have a hard limit on PHP values. For example, shared hosting often caps upload_max_filesize at 64M or 128M. If you need more, you may need to upgrade your plan or contact support.
Do I need to restart anything after changing PHP settings?
Usually no. PHP settings changes take effect immediately for new requests. However, if you’re using opcode caching (like OPcache), you might need to wait a few minutes or clear the cache in your hosting panel.
Can I change PHP settings on a local WordPress installation?
Yes. On a local environment like XAMPP or MAMP, you can edit the php.ini file in your PHP installation directory. The steps are similar, but you’ll need to restart the local server for changes to take effect.
What if I don’t have access to the server files?
If you’re on a managed host, you might not have FTP or file manager access. In that case, contact your host’s support and ask them to change the specific PHP setting for you. Some hosts also allow you to request changes via a ticket.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.