请求未等待PHP长进程,返回503服务不可用

请求未等待PHP长进程,返回503服务不可用,php,apache,http,Php,Apache,Http,我想通过使用PHP中的ini_set函数来测试max_execution_time设置。因此,我设置了一个简单的测试,创建一个无限循环,以确保它将超时 这是我的密码 Test.php <?php ini_set('max_execution_time', 300); echo "Hello World"; //for(;;); Commented, see history sleep(100); ?> 它甚至不需要等待5分钟。它在1分钟后

我想通过使用PHP中的ini_set函数来测试max_execution_time设置。因此,我设置了一个简单的测试,创建一个无限循环,以确保它将超时

这是我的密码

Test.php
<?php         
   ini_set('max_execution_time', 300);
   echo "Hello World";
   //for(;;); Commented, see history
   sleep(100);

?>
它甚至不需要等待5分钟。它在1分钟后一直会出错。但是在我的错误日志中,Apache在5分钟后写入超过时间的致命错误

因此,在我看来,请求在PHP脚本实际完成之前就被取消了

我使用apache2.conf上的默认设置和我的虚拟主机

apache2.conf (additional only)
<Directory /var/www/mysite.com/public>
    Options FollowSymLinks
    AllowOverride All
</Directory>

mysite.virtualhost.conf

<VirtualHost virtualhost.mysite.com:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerAdmin admin@mysite.com
    ServerName virtualhost.mysite.com
    ServerAlias virtualhost.mysite.com
    DocumentRoot /var/www/mysite.com/public

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
那么,我错过了什么配置?我认为我的apache配置有问题,但我不知道是哪一部分

更新

在查看进程运行后,运行无限循环的apache进程消耗了99%的CPU。为什么会这样?使用strace查看返回此

write(10, "36.72.135.58 - - [22/Jul/2016:03:15:35 +0700] \"GET /test11.php HTTP/1.1\" 500 211 \"-\" \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36\"\n", 198) = 198
times({tms_utime=29996, tms_stime=4, tms_cutime=0, tms_cstime=0}) = 4967918020
gettimeofday({1469132442, 496002}, NULL) = 0
gettimeofday({1469132442, 496046}, NULL) = 0
shutdown(17, SHUT_WR)                   = 0
poll([{fd=17, events=POLLIN}], 1, 2000) = 1 ([{fd=17, revents=POLLIN|POLLHUP}])
read(17, "", 512)                       = 0
close(17)                               = 0
read(5, 0x7fff82f5cf67, 1)              = -1 EAGAIN (Resource temporarily unavailable)
gettimeofday({1469132442, 496411}, NULL) = 0
accept4(4,  <detached ...>
write(10,“36.72.135.58---[22/Jul/2016:03:15:35+0700]\“GET/test11.php HTTP/1.1\“500 211\”-“\”Mozilla/5.0(Windows NT 10.0;WOW64)AppleWebKit/537.36(KHTML,像Gecko)Chrome/51.0.2704.103 Safari/537.36\“\n”,198)=
时间({tms_utime=29996,tms_stime=4,tms_utime=0,tms_cstime=0})=4967918020
gettimeofday({1469132442,496002},NULL)=0
gettimeofday({1469132442,496046},NULL)=0
停堆(17,停堆)=0
poll([{fd=17,events=POLLIN}],12000)=1([{fd=17,revents=POLLIN | POLLHUP}])
读(17,“,512)=0
关闭(17)=0
读取(5,0x7fff82f5cf67,1)=-1 EAGAIN(资源暂时不可用)
gettimeofday({1469132442,496411},NULL)=0
接受4(4,

我遇到了这个问题,我解决了在
/etc/varnish/default.vcl默认值为60,根据您的需要进行更改。

什么php配置?并非所有配置都允许通过ini_设置覆盖ini设置我添加了关闭php安全模式,它实际上覆盖了php.ini的最大执行时间,因为它甚至更长,为1200。将使用php.ini配置更新我的问题
503
响应代码使得VPS和您之间很可能存在某种代理或其他网关,配置了较低的超时。503响应来自服务器,这与您的浏览器中止请求不同(不会有http响应)因为它花费了太长的时间,或者中间的东西只是轰炸和关闭连接。你知道更多关于你的主机平台吗?他们提供什么样的地理负载平衡或DDoS保护?像这样的服务可能意味着其他事情在起作用。如果PHP运行为CGI或Apache模块?你确定是Apache WRI吗?5分钟后出现致命错误,而不是像php fpm那样写入自己的日志?php作为Apache模块运行。我使用digital ocean作为VPS提供程序。知道那里可能有什么样的代理吗?还有一个Apache tomcat实例也在运行该机。
Php.ini
safe_mode = off
max_execution_time = 1200
write(10, "36.72.135.58 - - [22/Jul/2016:03:15:35 +0700] \"GET /test11.php HTTP/1.1\" 500 211 \"-\" \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36\"\n", 198) = 198
times({tms_utime=29996, tms_stime=4, tms_cutime=0, tms_cstime=0}) = 4967918020
gettimeofday({1469132442, 496002}, NULL) = 0
gettimeofday({1469132442, 496046}, NULL) = 0
shutdown(17, SHUT_WR)                   = 0
poll([{fd=17, events=POLLIN}], 1, 2000) = 1 ([{fd=17, revents=POLLIN|POLLHUP}])
read(17, "", 512)                       = 0
close(17)                               = 0
read(5, 0x7fff82f5cf67, 1)              = -1 EAGAIN (Resource temporarily unavailable)
gettimeofday({1469132442, 496411}, NULL) = 0
accept4(4,  <detached ...>