Often when clients run WordPress on shared hosting they eventually run into PHP errors like maximum execution time or out of memory errors. This as inevitably you will run into coding errors causing this or the use of plugins or themes that are simply more demanding. Here are the possible solutions to deal with these errors.
Maximum Execution Time Exceeded
To fix PHP maximum execution time errors like:
PHP Fatal error: Maximum execution time of 120 seconds exceeded in /home/[user-name]/public_html/wp-content/plugins/pagefrog/admin/class-pagefrog-instant-articles-parser.php on line 755
you can add the following to your .htaccess:
php_value max_execution_time 300
or by adding this to you PHP ini:
max_execution_time = 300;
If you run Nginx and need to do these changes in PHP-FPM you need to edit
request_terminate_timeout = 300
Out of Memory Errors
The other error you often get using heavier plugins like WooCommerce or Revolution Slider is an error like:
Fatal error: Out of memory (allocated 1827405824) (tried to allocate 88800 bytes)
To deal with this you can add the following to .htaccess:
php_value memory_limit 128M
and in PHP.ini:
memory_limit = 128M;
In Nginx you could add:
to /etc/php5/fpm/php-fpm.conf .
There are several caveats I want to tell you about:
- so remember that these values depend on your server’s limitations and that this will be the limit for each concurrent PHP process.
- all values set can be and should be adjusted to your needs
- each server setup has different rules: sometimes php.ini cannot be edited, sometimes nothing at all and sometimes these changes have to done from a control panel