Updated: 29 September 2026 · Applies to: CWP (Control Web Panel) on AlmaLinux 8 and 9 and other Enterprise Linux 8 and 9 servers, with Apache and PHP-FPM

When a PHP script runs longer than a minute on a CWP server with Apache and PHP-FPM, visitors may see a "504 Gateway Timeout" or "The timeout specified has expired" error. Apache waits for PHP-FPM for 60 seconds by default and then gives up, even if PHP itself would allow more time. You raise this limit with a custom web server template in CWP. The steps below follow CWP's own documentation.

1. Create a custom template

Copy the default Apache templates for PHP-FPM (the .tpl file is for HTTP, the .stpl file for HTTPS):

cd /usr/local/cwpsrv/htdocs/resources/conf/web_servers/vhosts/httpd/php-fpm/
cp default.tpl timeout.tpl
cp default.stpl timeout.stpl

2. Add the timeout

In both new files, add a ProxyTimeout line inside the <IfModule proxy_fcgi_module> block, for example 120 seconds:

<IfModule proxy_fcgi_module>
    ProxyTimeout 120
    <FilesMatch \.php$>
        SetHandler "proxy:%backend_fcgi%|fcgi://localhost"
    </FilesMatch>
</IfModule>

Keep the rest of the block as it is in your copy. Use the lowest value that works: long timeouts let slow or stuck scripts tie up server resources.

3. Use the template

  • For one domain: in the CWP admin panel, WebServer Settings > WebServers Domain Conf, choose the domain and select the timeout template.
  • For the whole server: WebServer Settings > WebServers Main Conf, and select it as the default template.

CWP rebuilds the virtual host and restarts Apache. If something goes wrong, check /var/log/cwp/webservers.log.

4. Raise the PHP limits too

Apache's timeout is only one of the limits. The script also needs enough time in PHP:

  • max_execution_time in the PHP settings of the domain's PHP version (CWP's PHP-FPM selector or php.ini), for example 120.
  • request_terminate_timeout in the PHP-FPM pool, if it is set; it ends a request regardless of max_execution_time.
  • With Nginx in front of Apache (CWP's Nginx and Apache mode), Nginx has its own proxy_read_timeout, which must also be long enough.

For tasks that really take minutes, such as imports or backups, a cron job or a command-line script is usually better than a web request.

If you would rather have us manage the panel, see our managed CWP VPS. For another common CWP fix, see how to fix the File Manager upload error in CWP.

Official documentation: CWP: Apache proxy timeout with PHP-FPM and CWP: web server vhost templates.

Was this answer helpful? 0 Users Found This Useful (0 Votes)