WordPress Maximum Execution Time Exceeded Solutions on Ubuntu Linux

telework 5059653 640
telework 5059653 640

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 the 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 platforms:

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

The error above mostly occurs when 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 a 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, and upload themes, and plugins in WordPress.

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

Hosting WordPress on a Dedicated (Ubuntu) Server

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

First, determine when PHP is loaded from.

A simple way to find where the 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 module configurat when you run the command aboveions. The main file you’re looking for is the 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 the 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 suit 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 works with Apache2, Nginx, and Nginx with PHP-FPM.

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 the 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 it as a backup.

Open it and added the highlighted line

php_value max_input_time 1000
php_value max_execution_time 300
php_value post_max_size 64M
php_value upload_max_filesize 64M
php_value memory_limit 256M

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:

Posted by
Richard W

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

Leave a Reply

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

%d bloggers like this: