我正在尝试使用 docker-compose 和套接字文件配置运行 nginx 和 hhvm,但它返回 502 错误。我可以从 nginx 和 hhvm 映像访问 conf/hhvm/run/。在 nginx 的 error.log 文件中,我得到:
[error] 5#5: *3 connect() to unix:/var/run/hhvm/hhvm.sock failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/hhvm/hhvm.sock:", host: "xxxxxxx.io", referrer: "http://xxxxxxx.io/"
docker-compose文件:
nginx:
image: nginx
restart: always
ports:
- 80:80
log_driver: syslog
links:
- hhvm
volumes:
- ./www:/var/www/wp:rw
- ./conf/nginx:/etc/nginx:rw
- ./log/nginx:/var/log/nginx
- ./conf/hhvm/run:/var/run/hhvm
hhvm:
image: diegomarangoni/hhvm
volumes:
- ./log/hhvm:/var/log/hhvm
- ./conf/hhvm/run:/var/run/hhvm
- ./conf/hhvm:/etc/hhvm:rw
command: hhvm -u nginx -m server -vServer.Type=fastcgi -vLog.Level=Verbose
Nginx的:
nginx.conf 文件:
user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
gzip on;
gzip_disable "msie6";
open_file_cache max=100;
server {
listen 80;
server_name xxxxxxx.io;
root /var/www/wp;
index index.html index.htm index.hh index.php;
include /etc/nginx/hhvm.conf;
location / {
try_files $uri $uri/ /index.php?$args;
}
}
}
hhvm.conf:
location ~ \.(hh|php)$ {
fastcgi_keep_conn on;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
嗯:
php.ini文件:
; php options
session.save_handler = files
session.save_path = /var/lib/hhvm/sessions
session.gc_maxlifetime = 1440
; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
服务器.ini:
; php options
pid = /var/run/hhvm/pid
; hhvm specific
hhvm.server.file_socket=/var/run/hhvm/hhvm.sock
hhvm.server.type = fastcgi
hhvm.server.default_document = /var/www/wp/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
编辑: 如果我使用 jolicode/hhvm 图像而不是 diegomaragon/hhvm,我会收到一个新错误:
hhvm_1 | WARNING: Logging before InitGoogleLogging() is written to STDERR
hhvm_1 | E1214 23:22:35.751377 1 fastcgi-server.cpp:104] 13failed to bind to async server socket: 0.0.0.0:80: Permission denied
hhvm_1 | Permission denied listening on port 80
hhvm_1 | Unable to start page server
hhvm_1 | Shutting down due to failure(s) to bind in HttpServer::runAndExitProcess
docker_hhvm_1 exited with code 1