How to increase Apache TimeOut in CWP – Control WebPanel

Today I’ll show you how you can easily increase Apache timeout in CWP control web panel. If you’re frequently getting “504 Gateway Timeout” and your php script is timing out when uploading or doing long execution/process even after you increased the max_execution_time in php. Then this tutorial is for you.

Lets get started we will increase Apache timeout in 2 cases like if you’re using PHP-CGI SAPI and PHP-FPM SAPI i.e.  php switcher and selector are using php-cgi and php-fpm selector using FPM SAPI, you know 🙂

When using php-cgi add this in httpd.conf or create a config file :

TimeOut 3600

Add it in Apache config by creating a config file in conf.d dir :

touch /usr/local/apache/conf.d/timeout.conf
echo "TimeOut 3600" > /usr/local/apache/conf.d/timeout.conf
service httpd restart

When using PHP-FPM add this in domain vhosts under “proxy_fcgi_module” config:

Domain Apache vhosts location is in /usr/local/apache/conf.d/vhosts

ProxyTimeout 3600

eg :

<IfModule proxy_fcgi_module> 
<FilesMatch \.php>
SetHandler "proxy:unix:/opt/alt/php-fpm74/usr/var/sockets/username.sock|fcgi://localhost" 
</FilesMatch>
ProxyTimeout 3600
</IfModule>

you can also create a Apache vhost template and add the ProxyTimeout there and use it for the domain you need for increased timeout. You can copy default.stpl and default.tpl to timeout.stpl and timeout.tpl with same content only with below replace config :

php-fpm default templates can be found here :

/usr/local/cwpsrv/htdocs/resources/conf/web_servers/vhosts/httpd/php-fpm

eg :

replace :

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

with :

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

after you created the template go to webserver domain config and select the template there under php-fpm thats it or choose default trmeplate in webserver main conf and don’t forget to restart Apache web server if you manually added the timeout in vhost.

If you need Unlimited timeout then you need to disable this apache module :

LoadModule reqtimeout_module modules/mod_reqtimeout.so

go to /usr/local/apache/conf and edit httpd.conf find this line LoadModule reqtimeout_module modules/mod_reqtimeout.so and comment it out i.e. add “#” before this line. Save it and restart Apache server

eg :

#LoadModule reqtimeout_module modules/mod_reqtimeout.so
Back to top button