HHVM 回退到 PHP-FPM

HHVM 回退到 PHP-FPM

我在 nginx 上运行一个 PHP 应用程序,以 HHVM 作为主程序,以 PHP-FPM 作为备份

这是我的 nginx 配置,关于 php 处理

  location ~ \.(hh|php)$ {
    fastcgi_intercept_errors on;
    error_page 500 501 502 503 = @fallback;

    try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_keep_conn on;

    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param   SERVER_NAME $host;
    fastcgi_pass    127.0.0.1:9000;
  }

  location @fallback {

    try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param   SERVER_NAME $host;
    fastcgi_pass    unix:/var/run/php5-fpm.sock;

  }

为了测试配置,我停止了 hhvm 服务。通常,这会将请求传递给 PHP-FPM 并返回 200,但我收到以下 502 错误:

12296#0: *17 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.34.235, server: stylep3.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host:localhost

我在这里做错什么了吗

答案1

我发现 hhvm 在 nginx 的默认 vhost 文件中包含 hhvm.conf。

这就是处理请求并发送错误。

我修改了配置为

upstream php_backend {
  server 127.0.0.1:9000;
  server unix:/var/run/php5-fpm.sock backup;
}


server {
#
# other conf...
#

 location ~ \.(hh|php)$ {
    fastcgi_intercept_errors on;

    try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_keep_conn on;

    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param   SERVER_NAME $host;
    fastcgi_pass    php_backend;
  }

}

并删除了以下行

include hhvm.conf

来自vhost文件。

问题解决了!

相关内容