Search Our Database

How to add/edit the PHP “max execution time” with “.htaccess” File through SSH

Last updated on |

Introduction

Adjusting the PHP “max execution time” ensures that long-running scripts on your website do not time out prematurely. This setting is particularly important for PHP-based websites, such as WordPress, where complex operations may take longer to execute. One straightforward way to modify this value is through your website’s .htaccess file located in the public_html directory. This guide is designed for website administrators or developers seeking to increase the PHP max execution time to prevent script interruptions. You’ll learn the steps to safely update this setting and when it is necessary to apply these changes, particularly if you are facing timeout issues during large uploads, updates, or backups. The solution is applicable across most hosting environments that support the .htaccess file, offering a simple method to improve script performance.

Prerequisites

SSH login details details with either root or user level login for the domains

Basic Linux command experience

Step 1: Access the .htaccess File

To increase the max execution time in PHP, you need to create or edit “.htaccess” on the “public_html” folder of your website, if the .htaccess has already existed in the public_html folder, simply just edit the file and add the line as in the next step.

vi .htaccess

 

Step 2: Add the Max Execution Time Setting

Add the line below in the .htaccess file:-

php_value max_execution_time <value-that-you-want-to-set>

example:-

php_value max_execution_time 60

Save the changes to the .htaccess file

 

Conclusion

By following these steps, you can easily modify the PHP “max execution time” for your website, ensuring that your scripts have sufficient time to execute without interruptions. This adjustment can help prevent issues related to script timeouts and improve the performance of your website.