You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HHVM FastCGI模式无响应求助:Vagrant环境配置异常

Troubleshooting HHVM FastCGI Empty Response Error

Hey there, let's break down why you're seeing that ERR_EMPTY_RESPONSE when trying to access HHVM in FastCGI mode directly via localhost:9000, while the regular server mode works fine. The key difference here is how these two modes handle requests—let's dive into fixes:

1. Understand the Core Difference Between Modes

First off, FastCGI mode isn't an HTTP server—it's a backend process that only understands FastCGI protocol requests. When you hit localhost:9000 directly from your browser, you're sending an HTTP request, which FastCGI doesn't know how to process. That's why you get an empty response.

The hhvm -m server -p 9000 command starts an HTTP server, which does understand browser requests, hence it works perfectly.

2. Fix Your HHVM FastCGI Configuration

Check your /etc/hhvm/server.ini file to make sure it's explicitly set to run in FastCGI mode. You might be missing this critical line:

; php options
pid = /var/run/hhvm/pid

; hhvm specific
hhvm.server.port = 9000
hhvm.server.type = fastcgi  ; Add this line if it's missing!

After adding that line, restart HHVM to apply changes:

sudo service hhvm restart

3. Set Up a Web Server to Forward Requests

To access your PHP/HHVM code via FastCGI, you need a web server (like Nginx or Apache) to act as a middleman—converting browser HTTP requests to FastCGI requests that HHVM can handle.

Example Nginx Configuration

Edit your Nginx site config (e.g., /etc/nginx/sites-available/default) and add this block to handle PHP files:

server {
    listen 80;
    server_name localhost;
    root /path/to/your/web/root;  # Replace with your actual code directory

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Then restart Nginx:

sudo service nginx restart

Now, instead of accessing localhost:9000, visit localhost (port 80) in your browser—Nginx will forward the request to HHVM's FastCGI port and return the processed response.

4. Verify HHVM FastCGI is Running Correctly

Double-check that HHVM is actually listening on port 9000 in FastCGI mode:

ss -tulpn | grep hhvm

You should see output like:

tcp    LISTEN  0       128        127.0.0.1:9000      0.0.0.0:*    users:(("hhvm",pid=1234,fd=6))

If you don't see this, restart HHVM again and check the logs (/var/log/hhvm/error.log) for startup issues.

5. Test FastCGI Directly (Optional)

To confirm HHVM's FastCGI process is working, use the cgi-fcgi tool to send a test request:

echo -e "GET /index.php HTTP/1.1\r\nHost: localhost\r\n\r\n" | cgi-fcgi -bind -connect 127.0.0.1:9000

If you get a valid HTML/PHP response here, the problem is definitely in your web server configuration (not HHVM itself).


内容的提问来源于stack exchange,提问作者Syed Aqeel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:51:44