How to change timeout on PHP-Fpm

Discussion in 'General' started by helders, Oct 2, 2019.

  1. helders

    helders New Member

    Hello guys!

    I'm having some trouble increasing the timeout of PHP-Fpm, which currently sits at 300 seconds. I've tried changing the -idle-timeout on the FastCgiExternalServer line at the vhost template from 300 to 3000 but that didn't work. I saw some places recommending to add a timeout=3000 at the end of the ProxyPassMatch line (which is commented but i still tried) and didn't work aswell.

    I'm always getting this message on the errorlog:
    [Wed Oct 02 16:20:01.626223 2019] [proxy_fcgi:error] [pid 79540] (70007)The timeout specified has expired: [client 186.222.225.196:49887] AH01075: Error dispatching request to : (polling)

    I'm running on
    Debian 9
    Apache/2.4.25
    PHP 7.2.2
    ISPConfig 3.1.15

    Any ideas?

    On a side note, i have no idea why the proxy_fcgi is there, but don't know how to disable it anyway :(
     
  2. Hello, @helders
    Please follow these steps.
    Step 1:- Open php.ini file " vim /etc/php5/fpm/php.ini ".
    Note:- if you want to change max execution time limit for php script from 30 seconds(default) to 3000 seconds.
    Step 2:- Change max_execution_time = 3000.
    Step 3:-
    Open www.conf file " vim /etc/php5/fpm/pool.d/www.conf ".
    Step 4:-
    Change request_terminate_timeout = 3000.
    Step 5:-
    Open example.com file " vim /etc/nginx/sites-available/example.com ".
    Step 6:-
    Add following :
    location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_read_timeout 3000;
    }
    Step 7:- Open nginx.conf file " vim /etc/nginx/nginx.conf ".
    Step 8:-
    Add following in http{...} section.
    http{
    #...
    fastcgi_read_timeout 3000;
    #...
    }
    Step 9:-
    Reload PHP-FPM and Nginx.
    service php5-fpm reload
    service nginx reload


    I hope above information will be useful for you.
    Thank you.
     
  3. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    OP uses apache, not nginx. You seem to assume OP uses PHP version 5, when OP stated he has PHP 7.2.
    I would say your answer is not very useful.
     
  4. Steini86

    Steini86 Active Member

    In ISPconfig, go to Sites->Websites-Yoursite, then under "options" in the field "Custom php.ini settings" put:
    Code:
    max_execution_time = 3000
    Click save and wait until it is processed. Done.

    If you want to do it for all your Websites, it might be easier to edit the php.ini file directly.
     
  5. Greaves

    Greaves New Member

    What's the difference between doing this and editing the php.ini file directly? Is it only the number of websites impacted?
     
  6. Taleman

    Taleman Well-Known Member HowtoForge Supporter

  7. Steini86

    Steini86 Active Member

    It depends on your system and php configuration, but you can think of:
    php_fpm first loads the general configuration file (/etc/php/7.3/fpm/php.ini), then parses the files in /etc/php/7.3/fpm/conf.d (loaded modules). Then the ispconfig configuration (per user) is applied. The last command overwrites the previous. So if you have "
    max_execution_time = 30" in your global php.ini, it gets overwritten by what is in conf.d and what ispconfig applies.

    In principle, you should leave the default configuration if possible (so that it will be updated with future upgrades) and do your changes in ispconfig. This will ensure it is the last which is applied and that it will not be overwritten by some updates. Also, ispconfig will make sure, that your changes will apply, even if you change technology (new php version, or fcgi..).
    To make a long story short: Do your changes in ispconfig, unless you know what you are doing ;-)
     

Share This Page