Updated for 2026: the original version stopped at “edit php.ini and change the value” — no restart, no verify, and nothing about PHP-FPM, which is how almost everyone runs PHP now. Here’s the complete job.
1. Find the value — and the right php.ini
PHP usually has several configuration files (CLI, FPM, Apache each load their own). Ask the SAPI you actually care about:
[root@server ~]# php -i | grep -E 'Loaded Configuration|max_execution_time' Loaded Configuration File => /etc/php.ini max_execution_time => 30 => 30 # For PHP-FPM, the web-facing config is usually: [root@server ~]# ls /etc/php-fpm.d/ /etc/php/*/fpm/php.ini 2>/dev/null
The default is 30 seconds. 0 means no limit.
2. Change it
Option A — php.ini (global, per SAPI):
[root@server ~]# grep -n '^max_execution_time' /etc/php.ini max_execution_time = 300
Option B — PHP-FPM pool (recommended; per-site, and can’t be overridden by scripts): in your pool file, e.g. /etc/php-fpm.d/www.conf:
php_admin_value[max_execution_time] = 300
Option C — per directory: a .user.ini next to the application (FPM/CGI only):
max_execution_time = 300
Option D — in code, for one script that legitimately runs long:
ini_set('max_execution_time', '300');
// or: set_time_limit(300);
Note Option D silently fails if the value was set with php_admin_value (Option B) — “admin” values are locked by design.
3. Restart what serves PHP
[root@server ~]# systemctl restart php-fpm # FPM setups [root@server ~]# systemctl restart httpd # mod_php setups
Skipping this step is the #1 reason “I changed it and nothing happened”.
4. Verify — on the web side, not just the CLI
The CLI and the web SAPI read different files, so a CLI check can lie to you. Verify through the actual site with a one-line phpinfo() page (create it, check it, delete it — a public phpinfo page is a gift to scanners):
<?php phpinfo();
Look for max_execution_time → Local Value. That’s the number your application actually lives under.
Notes
- CLI is different: command-line PHP defaults to
max_execution_time = 0(unlimited) regardless of php.ini — cron jobs and workers don’t need this fix. - Long requests die elsewhere too: if a request still times out, check the layer in front — Apache
TimeOut/ProxyTimeout, nginxfastcgi_read_timeout, and FPM’s ownrequest_terminate_timeoutall kill long-running PHP independently of this setting. - Raise it surgically. A global 900-second limit means a runaway script holds a worker for 15 minutes. Prefer the pool or per-script options for the one job that needs it.
Running your own server? These guides assume you have a Linux box somewhere — see our guide to choosing a VPS in 2026 for the 7 specs that actually matter before you spin one up.
