How to increase Apache TimeOut in CWP – Control WebPanel

by Sandeep B.

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-fpm72/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 and don’t forget to restart Apache web server if you manually added the timeout in vhost.

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

Donate with Paytm :

md-donate

You may also like

3 comments

Jose May 6, 2020 - 10:04 am

Thank you very much, Sandeep. You helped me with this process by ticketing through CWP and it worked well, thanks for the guidance.

Reply
Sujoy dhar June 26, 2020 - 12:58 pm

Can you please help me ?
My cpu usage is 15% but my website is getting timeout or not loading in centos web panel

Reply
Sandeep B. June 26, 2020 - 1:22 pm

https://forum.mysterydata.com/ is the right place ask here you’ll definitely get helped.

Reply

Leave a Comment