How to Increase PHP Max Execution Time WordPress
Last edited on February 27, 2026

When managing a WordPress website, you may eventually encounter a frustrating error message:

Fatal error: Maximum execution time of 30 seconds exceeded

This error typically appears during plugin installations, theme updates, large imports, backups, or heavy database operations. It happens because PHP stops a script that runs longer than the server allowed time limit.

Understanding how this works and how to properly increase it is essential for website owners, developers, and server administrators.

In this guide, we’ll explain everything in detail, including what max execution time means, why it exists, when you should increase it, and the safest methods to do so.

What Is PHP Max Execution Time?

maximum execution time

PHP is the scripting language that powers WordPress. Every time someone visits your website, PHP executes scripts to generate the page dynamically.

To prevent server abuse and infinite loops, PHP sets a time limit for how long a script can run. This limit is controlled by a configuration directive called:

max_execution_time
The value is measured in seconds.
For example:
max_execution_time = 30

This means any PHP script running longer than 30 seconds will automatically terminate.

Why Does PHP Have a Time Limit?

The execution time limit exists for several important reasons:

1. Server Protection

Without limits, poorly written scripts could run endlessly and consume CPU resources.

2. Shared Hosting Stability

On shared servers, one website using excessive resources can affect other users.

3. Security Control

Malicious scripts could intentionally run long processes to overload the system.

The time limit acts as a safeguard to keep servers stable and responsive.

Why You Might Need to Increase Max Execution Time

While the default limit (often 30 seconds) works for basic page loads, certain operations require more time.

Common scenarios include:

  • Importing large XML or CSV files
  • Installing heavy themes or plugins
  • Running WooCommerce product imports
  • Creating full website backups
  • Restoring large databases
  • Executing migration scripts
  • Bulk image optimization

If the process exceeds the limit, PHP terminates it mid-way, causing incomplete tasks or failure errors.

How to Confirm Your Current Execution Time

Before changing anything, it’s important to verify your current settings.

Method 1: Using phpinfo()

Create a file named:

info.php
Add the following code:
<?php
phpinfo();
?>

Upload it to your root directory and open:

yourdomain.com/info.php

Search for:

max_execution_time

This shows the active value set by your server.

Important: Delete this file after checking for security reasons.

Ideal Max Execution Time Values

There is no universal value that fits all websites. However, general recommendations are:

Use CaseRecommended Time
Basic WordPress site60–120 seconds
Medium website with imports180–300 seconds
Large backups or migrations300–600 seconds

Avoid setting extremely high values unless necessary.

Methods to Increase PHP Max Execution Time

Now let’s explore every reliable method, from beginner-friendly to advanced server-level changes.

Editing php.ini (Most Effective Method)

If you have VPS, dedicated hosting, or root access, editing php.ini is the most reliable way.

Step 1: Locate php.ini

Common locations include:

/etc/php/8.x/apache2/php.ini
/etc/php/8.x/fpm/php.ini

Step 2: Find the Directive

Search for:

max_execution_time = 30

Step 3: Increase the Value

Example:

max_execution_time = 300

This allows scripts to run for 5 minutes.

Step 4: Restart Web Server

After saving changes, restart:

Apache:

sudo systemctl restart apache2

Nginx:

sudo systemctl restart nginx

Without restarting, changes won’t apply.

Increase Execution Time via .htaccess(Apache Servers)

If your website runs on Apache and your hosting provider allows overrides, you can modify execution time directly inside the .htaccess file.

Step 1: Locate .htaccess

The file is usually inside your WordPress root directory:

public_html/

Step 2: Add This Line

php_value max_execution_time 300

This increases the limit to 300 seconds.

When This Method Fails

You may see an Internal Server Error (500) after adding this line. This happens if:

• Your host disables PHP overrides in .htaccess
• You are running PHP-FPM
• The server is using Nginx instead of Apache

If that happens, remove the line immediately and try another method below.

Increase Time Using wp-config.php

WordPress allows you to extend execution time without touching server files.

Step 1: Open wp-config.php

It’s located in the WordPress root directory.

Step 2: Add This Line

Place it above:

/* That's all, stop editing! */

Add:

set_time_limit(300);

This instructs PHP to allow 5 minutes for script execution.

Important Note

This method works only if the server configuration allows runtime changes. Some hosting providers restrict it.

Using ini_set()Inside PHP Files

If you need to increase execution time for a specific script (for example, a custom import tool), you can add:

ini_set('max_execution_time', '300');

Place it at the top of the PHP file.

This method is ideal for:

  • Custom plugins
  • Import/export scripts
  • igration tools

It does not change the limit globally, only for that specific script.

Adjust via cPanel or Hosting Dashboard

Many hosting providers offer an easy interface for modifying PHP settings.

In cPanel:

  1. Login to cPanel
  2. Go to Select PHP Version
  3. Click Options
  4. Find max_execution_time
  5. Change it to 300 or higher.
  6. Save changes

This is the safest method for non-technical users.

Nginx Server Configuration

If your server uses Nginx, .htaccess will not work.

You must edit your Nginx configuration file.

Step 1: Locate the configuration

Common paths:

/etc/nginx/nginx.conf

/etc/nginx/sites-available/default

Step 2: Add inside the server block

location ~ \.php$ {
   include fastcgi_params;
   fastcgi_read_timeout 300;
}

Step 3: Restart Nginx

sudo systemctl restart nginx

This adjusts the timeout for PHP processing under Nginx.

PHP-FPM Configuration

If your server uses PHP-FPM, the limit might be controlled inside the FPM pool configuration.

Step 1: Locate the FPM file

/etc/php/8.x/fpm/pool.d/www.conf

Step 2: Add or modify

request_terminate_timeout = 300

Step 3: Restart PHP-FPM

sudo systemctl restart php8.x-fpm

Replace the version number accordingly.

Troubleshooting Execution Time Errors

Sometimes, increasing max execution time does not solve the issue. Here’s why:

1. Memory Limit Is Too Low

If your memory limit is small, the script may fail before time runs out.

Check:

memory_limit

2. Server-Level Timeout Overrides

Some hosts enforce hard limits that cannot be overridden via WordPress.

If none of the methods work, contact hosting support and request:

  • Increased max execution time
  • Increased PHP-FPM timeout
  • Increased web server timeout

3. Long-Running Scripts Should Be Optimized

An increasing time limit is not always the best solution.

Better alternatives:

  • Break large imports into batches
  • Use WP-CLI for heavy tasks
  • Optimize database queries
  • Increase server resources

Security and Performance Considerations

Setting extremely high values like:

max_execution_time = 0

means unlimited execution time.

This is dangerous because:

  • Infinite loops can crash the server
  • Malicious scripts can abuse resources
  • Server CPU usage may spike

Always choose a reasonable value based on your use case.

Best Practice Recommendation

For most WordPress websites:

  • Set execution time between 180 and 300 seconds
  • Increase memory_limit to at least 256M
  • Use WP-CLI for heavy operations
  • Avoid unlimited execution time

Final Thoughts

Increasing PHP max execution time can be an effective way to prevent interruptions during resource-intensive tasks such as installing large plugins, performing bulk imports, handling website migrations, generating full site backups, or running complex WooCommerce operations. These processes often require more processing time than the default server limit allows, and extending the execution window ensures they complete without being prematurely terminated.

However, raising this limit should never be your first or only solution. Timeouts are often a symptom of deeper issues such as inefficient code, low memory limits, server resource constraints, or unoptimized database queries. Simply increasing the value to an extremely high number may temporarily hide the problem rather than solve it.

A smarter approach is to identify the root cause of the delay and combine an appropriate execution time setting with proper server configuration, adequate memory allocation, and optimized scripts. This balanced strategy helps maintain both performance and long-term stability, ensuring your website runs efficiently without compromising server health.

About the writer

Hassan Tahir Author

Hassan Tahir wrote this article, drawing on his experience to clarify WordPress concepts and enhance developer understanding. Through his work, he aims to help both beginners and professionals refine their skills and tackle WordPress projects with greater confidence.

Leave a Reply

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

Lifetime Solutions:

VPS SSD

Lifetime Hosting

Lifetime Dedicated Servers