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 服務。

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

來自虛擬主機檔案。

這解決了問題!

相關內容