WordPress Maximum Execution Time Exceeded Solutions on Ubuntu 18.04 | 16.04

WordPress, the most popular content management system (CMS) can be configured in many ways on many different platforms… If you’re hosting WordPress on a dedicated server where you have root access, you can customize WordPress environment for maximum performance..

If you’re hosting WordPress on a shared platform, you’re limited in most cases by how the hosting provider’s systems are configured..

This brief tutorial shows you how to resolve this frequent error when running WordPress on some platform:

‘Fatal error: Maximum execution time of 30 seconds exceeded’

The error above mostly occur when you’re trying to update a WordPress plugin or theme.. and it happens when a PHP code in WordPress takes a long time to run and reaches the maximum time limit set on the server..

This can be configured in PHP configuration file or within WordPress configuration..

By default, the maximum execution time is set between 30 – 60 seconds after PHP is installed… Sometimes, it takes a long time to update, upload themes, plugin in WordPress..

If it takes longer than 30 seconds, the PHP process will fail and display that error… Below is how to resolve:

Step 1: Hosting WordPress on Dedicated (Ubuntu) Server

If you’re hosting WordPress on a dedicated server with root access via SSH, then you simple run the commands below to open PHP main configuration file…

First determine when PHP is loaded from..

A simple way to find where PHP default configurations file is stored is to run the command below

php --ini

When you run the command above, you’ll see a list of locations for PHP modules configurations. The main file you’re looking for is Loaded Configuration File. This is the default configuration file that is loaded each time PHP runs.

Configuration File (php.ini) Path: /etc/php/7.2/cli
Loaded Configuration File: /etc/php/7.2/cli/php.ini
Scan for additional .ini files in: /etc/php/7.2/cli/conf.d
Additional .ini files parsed: /etc/php/7.2/cli/conf.d/10-mysqlnd.ini,

Now that you know, simply run the commands below open PHP default configuration files… (Apache2, Nginx and Cli)

sudo nano /etc/php/7.2/cli/php.ini
sudo nano /etc/php/7.2/apache2/php.ini
sudo nano /etc/php/7.2/nginx/php.ini

Then use the down arrow key to scroll down in the file and modify these highlighted lines. You should see the section that reads “PHP Limits”, below that you’ll find PHP default file maximum upload size as well..

;PHP Limits
;
max_execution_time = 600 
max_input_time = 900 
memory_limit = 256M 
post_max_size = 32M
;
;
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 100M

When you’re done changing the lines to suite your environment, save and exit… then restart your webserver and PHP..

sudo systemctl reload apache2.service
sudo systemctl reload nginx.service
sudo systemctl reload php7.2-fpm.service

Each line above work with Apache2, Nginx and Nginx with PHP-FPM…

Step 2: Shared Hosting Environment

If you’re on a shared hosting environment with web-based access to your files from a hosting tool, then use the steps below to configure..

From the root directory where WordPress files are, you’ll mostly see a .htaccess file there.. WordPress uses this file to manipulate how Apache (server) serves files from its root directory, and subdirectories…

If you’re running WordPress on a host using Nginx, then this file might not be useful… Since host hosting providers offer Apahce2 Web hosting, you might see one..

Browse to WordPress directory…

WordPress directory

  • Go to the root directory, it’s the directory where you can find your wp-config.php file. You should be able to find your .htaccess file.
  • Download a copy of it onto your computer to save as backup.
  • Open it and added the highlighted line
    php_value memory_limit 256M
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 1000
    

If you’re using FTP/sFTP to connect to your host and edit… then edit the file and add the lines above.. then save to upload the changes..

WordPress Setup

Once you’re done… try to do what you couldn’t do before…

In most cases, the settings above should resolve your problem… If not, then you may have other issues at the system’s level.. Contact your host provider for assistance..

That should do it! Hope you like this post…

You may also like the post below:

Setup Joomla with Apache2 and Ubuntu 18.04 on Google Cloud

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.