PHP timeout-php-cgi calls external program timeout, but PHP can run the external program completely in command line mode

Source: Internet
Author: User
Operating environment is Ubuntu14.04
PHP script


  
   

Either Apache or Nginx terminates when the R language is half running (the step stops when you need to wait 3-5 seconds to run)

But with PHP in command-line mode
Php-f result.php
It can be run completely.

Can you solve this problem by modifying the PHP configuration?

Reply content:

Operating environment is Ubuntu14.04
PHP script


  
   

Either Apache or Nginx terminates when the R language is half running (the step stops when you need to wait 3-5 seconds to run)

But with PHP in command-line mode
Php-f result.php
It can be run completely.

Can you solve this problem by modifying the PHP configuration?

This article is written in very detailed (English): https://rtcamp.com/tutorials/php/increase-script-execution-time/

To summarize:

    • PHP.ini: max_execution_time should be long enough
    • Php-fpm.ini: request_terminate_timeout should be long enough
    • Nginx: fastcgi_read_timeout should be long enough

First of all, there is no limit to the php-cli of the script run time. You can refer to http://www.php100.com/manual/php/features.commandline.html. A regular web request is expected to respond in a short time, so the normal php-cgi script execution is limited by the maximum execution time of the configuration file, Apache fortunately some, nginx through proxy to forward the request, it will also set a maximum waiting time here, A similar error was returned 5** the time-out. If your task takes a long time to execute, it is recommended that you do not use HTTP to access PHP, you can switch to background execution

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.