在ubuntu14.04上使用ngnix配置简单的hhvm站点(hack-site-example)的问题

时间:2014-08-31 01:35:38

标签: hhvm hacklang

我按照https://github.com/hhvm/hack-example-site处的说明进行操作,并且在通过ubunut 14.04在ngnix上设置hhvm hack网站时迷路了。请注意,我使用了适当的apt-get repo for 14.04。

但是在配置并尝试访问127.0.0.1:9000后,我在/var/log/hhvm/error.log中看到错误

FastCGI protocol: received an invalid record

我的/ etc / ngnix / sites-enabled如下

-rw-r--r-- 1 root root  0 Aug 30 22:01 default
lrwxrwxrwx 1 root root 44 Aug 30 22:21 hack-example-site -> /etc/nginx/sites-available/hack-example-site

/ etc / ngnix / sites-available / hack-example-site的内容如下:

server {
  root ~/hack-example-site/hack-example-site;
  index index.php;
  location ~ \.php$ {
    # If fastcgi backend is on another server disable this.
    # Read issue #6 about this
    try_files $uri =404;

    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    #fastcgi_param SCRIPT_FILENAME ~/hack-example-site/hack-example-site/index.php
    fastcgi_param ~/hack-example-site/hack-example-site        $document_root$fastcgi_script_name;
    include fastcgi_params;
  } 
}

有人可以帮助我在我的本地主机上运行这个hhvm网站吗?感谢。

哦,请注意ngnix已正确安装,服务器响应localhost。

下面的配置文件/ etc / nginx / sites-available / hack-example-site:

server {
  root /root/hack-example-site;
  index index.php;
  server_name localhost;
  location ~ \.php$ {
# If fastcgi backend is on another server disable this.
# Read issue #6 about this
try_files $uri =404;

fastcgi_pass  127.0.0.1:9000;

fastcgi_index index.php;

#fastcgi_param SCRIPT_FILENAME ~/hack-example-site/hack-example-

网站/ index.php的

fastcgi_param /root/hack-example-site 

$ DOCUMENT_ROOT $ fastcgi_script_name;

include fastcgi_params;

} } 〜

1 个答案:

答案 0 :(得分:0)

我确实找到了一个可以测试我的黑客脚本的工作,但对此并不满意。我创建了符号链接

/etc/ngnix/sites-enabled/default->/etc/ngnix/sites-available/default.

复制了test.php,其中包含用hack编写的简单hello world到/ usr / share / nginx / html。编辑/ etc / nginx / sites-available / default,如下所示:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    #index index.html index.htm;
    index test.php;
    # Make site accessible from http://localhost/
    server_name localhost;
    include hhvm.conf;

现在,当我访问localhost时,hackscript被执行并且显示了Helloworld。

但是,我希望这可以使用/ etc / nginx / sites-available / hack-site-example而不是默认值。不确定那里会发生什么?任何人都可以投光吗?