2

我已将nginx设置为在 fast-cgi 模式下使用 HipHop VM 3.0 版。一些事实:

  1. 我在 Ubuntu 13.10 上运行
  2. nginx 和 hhvm 以用户身份运行www-data
  3. 用户 www-data 在组中fooers
  4. nginx 的服务器根目录是一个/srv/foo包含单个index.php文件的目录
  5. 组的所有权/srv/foo是组fooers
  6. /srv/foo权限设置为770

当我尝试查看此页面时,我得到一个 404 未找到,但在 hhvm 或 nginx 日志中都没有记录错误。但是,如果我将权限更改为页面775上的权限,则会完全按预期提供服务。/srv/foohhvmnginx

此外,如果我将 www-data 用户的默认组更改为 fooers 组,它的权限为 770。只有当它不是用户的默认组时,它似乎才会失败。

什么问题?!?!?有谁知道为什么当权限为 770 时,hhvm/nginx 以用户 www-data 的身份运行并具有对目录的组访问权限,但无法访问?

为了确认我的理智并确保我的组和权限与我认为的一样,在启动服务后,我运行

$> ps -aux

正如预期的那样,我看到了一个 hhvm 进程和运行的 nginx 进程www-data

www-data  3484 .... /usr/bin/hhvm --config /etc/hhvm/server.ini --user www-data --mode daemon -vPidFile=/var/run/hhvm/pid
www-data  3617 ... nginx: worker process 

当我检查我看到的组时:

$> groups www-data
www-data : www-data fooers

当我检查目录时,我可以确认对组和所有者的 100% 访问:

$> ls -al
total 16
drwxr-xr-x  5 root root   4096 Mar 30 15:57 .
drwxr-xr-x 22 root root   4096 Mar 30 11:52 ..
drwxrwx---  2 root fooers 4096 Mar 30 15:39 foo

如果我以www-data允许的用户身份检查文件的内容:

$> sudo -u www-data ls -al /srv/foo
total 12
drwxrwx--- 2 root fooers 4096 Mar 30 15:39 .
drwxr-xr-x 5 root root     4096 Mar 30 15:57 ..
-rw-rw-r-- 1 root fooers   38 Mar 30 15:39 index.php

如果我对不在 fooers 组中的用户尝试上述操作,则会失败。

这是我的/etc/hhvm/server.ini

; php options

pid = /var/run/hhvm/pid

; hhvm specific

hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
hhvm.mysql.typed_results = false

我真的希望这不是我忽略的愚蠢和明显的事情......

这是我的 Web 根目录的 nginx 位置块:

location ~ \.php$ {
    root /srv/foo
    fastcgi_keep_conn on;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME /srv/foo$fastcgi_script_name;
    include        fastcgi_params;
}
4

2 回答 2

1

请尝试更改您的配置文件,您的配置文件中没有 SourceRoot。我的一些配置被启动参数覆盖。

在这里看看它们:/usr/bin/hhvm --config /etc/hhvm/server.hdf --user www-data --mode daemon -vServer.Type=fastcgi -vServer.Port=9010

PidFile = /var/run/hhvm/pid

Server {
  Port = 82
  SourceRoot = /var/www/main/
  DefaultDocument = index.php
}

#AdminServer {
#    Port = 9088
#    ThreadCount = 1
#    Password = xxx
#}

Eval {
    Jit = true
    JitWarmupRequests = 5
}

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

#Repo {
#  Central {
#    Path = /var/run/hhvm.hhbc.sq3
#  }
#}

#include "/usr/share/hhvm/hdf/static.mime-types.hdf"
StaticFile {
  FilesMatch {
    * {
      pattern = .*\.(dll|exe)
      headers {
        * = Content-Disposition: attachment
      }
    }
  }
  Extensions : StaticMimeTypes
}

MySQL {
  TypedResults = false
}
于 2014-03-30T20:33:07.440 回答
0

This appears to be a bug with HHVM. I've added a ticket to fix this in there project.

于 2014-09-01T15:50:34.323 回答