Portal Home Knowledgebase 2. cPanel Web Hosting How to Increase Your PHP Maximum Execution Time

How to Increase Your PHP Maximum Execution Time Print

  • 0

PHP’s maximum execution time determines how long a script is allowed to run before it times out, commonly set to 30 seconds by default. This limit can cause issues for tasks that require longer processing, like sending bulk emails or performing large file imports and exports. Fortunately, in cPanel, you can adjust this setting as needed.

Steps to Increase PHP Maximum Execution Time in cPanel

  1. Log into Your cPanel Account:

    • Access cPanel by entering your username and password, or via your hosting provider’s client area.
  2. Navigate to PHP Selector:

    • In the Software section, look for Select PHP Version and click on it.
  3. Open the Options Tab:

    • Once inside the PHP Selector, go to the Options section to access the php.ini settings.
  4. Adjust max_execution_time:

    • Find max_execution_time and change its value. The default is typically 30 seconds, but you can set it higher, like 120 seconds (2 minutes) or 180 seconds (3 minutes), based on your needs.
    • Note: Setting the value to 0 makes it unlimited (use this cautiously).
  5. Save Your Changes:

    • Click anywhere outside the input box to confirm the change. A green confirmation box should appear if the change was applied successfully.

Verifying Execution Time

Use PHP’s phpinfo() function to check the current value of max_execution_time:

<?php phpinfo(); ?
840

Measuring Script Execution Time

To calculate a script's execution time, use the microtime() function at the start and end of the script:

<?php $start_time = microtime(true); // Your script here $end_time = microtime(true); $execution_time = $end_time - $start_time; echo "Execution time: " . $execution_time . " seconds"; ?>

This method is useful for optimizing scripts and understanding their impact on server performance. Adjusting max_execution_time in cPanel is straightforward and ensures that resource-intensive scripts run smoothly without unnecessary timeouts.


Was this answer helpful?

« Back