系统相关
首页 > 系统相关> > 配置 – 如何在nginx / HHVM中配置UNIX套接字?

配置 – 如何在nginx / HHVM中配置UNIX套接字?

作者:互联网

到目前为止,这就是我所做的:

$less /etc/nginx/hhvm.conf
location ~ \.(hh|php)${
    fastcgi_pass   unix:/var/run/hhvm/sock;
    include        fastcgi_params;
}

$less /etc/hhvm/server.ini
; php options

pid = /var/run/hhvm/pid

; hhvm specific 

hhvm.server.file_socket = /var/run/hhvm/sock
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc

它与正确的TCP端口配置完美配合,但用UNIX套接字配置替换它会导致与端口配置错误相同的nginx错误.

解决方法:

您应该检查文件权限.

nginx必须能够写入php5-fpm或hhvm Unix套接字.

您可以在nginx错误日志/var/log/nginx/error.log中找到类似这样的行,确认这是问题所在:

2015/10/28 16:32:24 [crit] 14845#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "HEAD /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost"

解决方案:将nginx用户添加到拥有套接字的用户组(通常是www-data).套接字文件应该可以由组写入,因此您最好使用以下命令:

# usermod -a -G www-data nginx

标签:nginx,configuration,hhvm
来源: https://codeday.me/bug/20190816/1672493.html