Prerequisites
Before changing PHP execution time, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
PHP Settings to Change
- max_execution_time - Maximum time in seconds a script can run (default: 30)
- max_input_time - Maximum time for parsing input data (default: 60)
Method 1: Edit php.ini
For PHP 8.2 FPM:
nano /etc/php/8.2/fpm/php.ini
Change values:
max_execution_time = 300
max_input_time = 300
For memory-intensive scripts, also increase:
memory_limit = 256M
Method 2: Change via .htaccess (Apache)
nano /home/admin/web/example.com/public_html/.htaccess
Add:
php_value max_execution_time 300
php_value max_input_time 300
Method 3: Change via .user.ini (Nginx/FPM)
nano /home/admin/web/example.com/public_html/.user.ini
Add:
max_execution_time = 300
max_input_time = 300
Method 4: Set Inside PHP Script
ini_set('max_execution_time', 300);
ini_set('max_input_time', 300);
Add at the beginning of your script.
Restart PHP-FPM After Changes
systemctl restart php8.2-fpm
Verify Execution Time
Create test script:
echo "" > /home/admin/web/example.com/public_html/time_test.php
Browse to https://example.com/time_test.php.
Recommended Execution Times
| Use Case | max_execution_time |
|---|---|
| Regular website | 30-60 seconds |
| WordPress (with plugins) | 60-120 seconds |
| Image processing | 180-300 seconds |
| Data import/export | 300-600 seconds |
| Video encoding | 600-3600 seconds |
⚠️ Setting execution time too high can tie up server resources. Use background jobs when possible.
✅ PHP execution time has been updated!