hhvm-fastcgi + nginx如何让它在浏览器中显示致命错误

Sat*_*ake 18 hhvm

我一直在玩HHVM配置文件,我还没有能够向浏览器输出任何致命错误.它显示E_NOTICE和E_WARNING,但是当发生任何E_ERROR时,它会使页面留空,并且错误仅出现在HHVM日志文件中.

有没有办法让它在浏览器中显示?

我的HHVM配置文件如下:

PidFile = /var/run/hhvm/pid

Log {
  Level = Warning
  AlwaysLogUnhandledExceptions = true
  RuntimeErrorReportingLevel = 8191
  UseLogFile = true
  UseSyslog = false
  File = /var/log/hhvm/error.log
  InjectedStackTrace = false
  NativeStackTrace = false
  Access {
    * {
      File = /var/log/hhvm/access.log
      Format = %h %l %u % t \"%r\" %>s %b
    }
  }
}

ErrorHandling {
  CallUserHandlerOnFatals = true
  NoInfiniteLoopDetection = false
  NoInfiniteRecursionDetection = false
  ThrowBadTypeExceptions = false
  ThrowNotices = false
  NoticeFrequency = 1    # 1 out of these many notices to log
  WarningFrequency = 1   # 1 out of these many warnings to log
  AssertActive = false
  AssertWarning = false
}

Debug {
  FullBacktrace = false
  ServerStackTrace = false
  ServerErrorMessage = false
  TranslateSource = false

  RecordInput = false
  ClearInputOnSuccess = true

  ProfilerOutputDir = /tmp

  CoreDumpReport = true
  CoreDumpReportDirectory = /tmp
}

Http {
  DefaultTimeout = 30 # in seconds
  SlowQueryThreshold = 5000 # in ms, log slow HTTP requests as errors
}

Mail {
  SendmailPath = sendmail -t -i
  ForceExtraParameters =
}

Preg {
 BacktraceLimit = 100000
 RecursionLimit = 100000
}

Repo {
  Central {
    Path = /var/log/hhvm/.hhvm.hhbc
  }
}

Eval {
  Jit = true
}

MySQL {
  TypedResults = false
  ReadOnly = false
  ConnectTimeout = 2000      # in ms
  ReadTimeout = 2000         # in ms
  SlowQueryThreshold = 2000  # in ms, log slow queries as errors
  KillOnTimeout = false
}
Run Code Online (Sandbox Code Playgroud)

Nginx的:

location ~ \.php$ {
    fastcgi_keep_conn on;

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_read_timeout 900;
    fastcgi_send_timeout 900;
    fastcgi_intercept_errors off;

    fastcgi_pass   127.0.0.1:9000;

    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)

Yog*_*ogu 3

您需要hhvm.server.implicit_flush在您的 中启用该配置php.ini,然后您可以在发生致命错误时发送响应正文。为了能够使用错误处理程序捕获致命错误,您还应该启用hhvm.error_handling.call_user_handler_on_fatals.

有关详细信息,请参阅hhvm 上的 github 问题