WordPress performance depends heavily on proper PHP configuration. Whether you run a simple business website or a complex setup with WooCommerce or page builders, setting the right PHP limits ensures better performance, stability, and user experience.
Recommended PHP Settings
For Heavy Websites (WooCommerce, Page Builders)
| Setting | Value |
|---|---|
| memory_limit | 512M |
| max_execution_time | 300 |
| max_input_time | 300 |
| max_input_vars | 5000 |
| post_max_size | 64M |
| upload_max_filesize | 64M |
For Basic Websites
| Setting | Value |
|---|---|
| memory_limit | 256M |
| max_execution_time | 120 |
| max_input_time | 120 |
| max_input_vars | 3000 |
| post_max_size | 32M |
| upload_max_filesize | 32M |
You can check your current PHP values in WordPress → Tools → Site Health → Info → Server.
Key PHP Settings Explained
- memory_limit – Maximum memory a script can use. Important for plugins and themes.
- max_execution_time – Maximum time a script can run before stopping.
- max_input_time – Time allowed to process input data like forms.
- max_input_vars – Maximum number of form inputs allowed.
- post_max_size – Maximum size of POST data (affects uploads).
- upload_max_filesize – Maximum size of a single uploaded file.
Why These Settings Matter
- Performance: Prevents slow or stuck scripts from affecting the server.
- Stability: Avoids crashes caused by memory exhaustion.
- Security: Limits abuse through large uploads or requests.
- User Experience: Enables smooth uploads, updates, and plugin operations.
In WordPress, low limits often cause errors like:
- Allowed memory size exhausted
- File upload failed
- Timeout during import or update
How to Update PHP Limits
1. Using php.ini (Best Method)
Add or update anywhere in the file (preferably under existing similar directives):
memory_limit = 256M
max_execution_time = 300
max_input_time = 300
max_input_vars = 5000
post_max_size = 64M
upload_max_filesize = 64M
2. Using .htaccess (Apache Only)
Add at the top of the file, before WordPress rules:
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300
php_value max_input_vars 5000
php_value post_max_size 64M
php_value upload_max_filesize 64M
3. Using wp-config.php
Add just above this line:
/* That's all, stop editing! Happy publishing. */@ini_set('memory_limit', '256M');
@ini_set('max_execution_time', '300');
@ini_set('max_input_time', '300');
@ini_set('max_input_vars', '5000');
@ini_set('post_max_size', '64M');
@ini_set('upload_max_filesize', '64M');
4. Using Hosting Panel
Most hosting providers offer tools like cPanel (MultiPHP INI Editor) or custom dashboards to update these values easily.
Best Practices
- Do not set values excessively high.
- Ensure
post_max_sizeis equal to or greater thanupload_max_filesize. - Use PHP 8.1 or higher for better performance.
- Enable OPcache if available.
- Optimize plugins instead of relying only on higher limits.
Conclusion
Proper PHP configuration is essential for a fast and stable WordPress site. By setting appropriate limits, you can avoid common errors, improve performance, and ensure your website runs smoothly under different workloads.