【发布时间】:2015-08-10 22:29:18
【问题描述】:
我正在使用 Nginx 服务器,以前从未使用过,所以如果我错过了一些愚蠢的事情,我深表歉意,但我对这一切都很陌生。
在我的 error.log 中我有:
[error] 2105#0: *87 connect() failed (111: Connection refused) while connecting to upstream, client: 86.58.251.66, server: premium.bookboon.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "premium.bookboon.com"
而且我不确定为什么会发生此错误。这是我的 nginx.conf:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
我已经看到通过修复一些 php-fpm 选项解决了很多这些问题,但是我正在使用的服务器似乎没有使用它,快速的 find / -name "php-fpm" 没有返回任何东西,所以我在这里有点失落。
/启用站点/默认值:
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name premium.bookboon.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
root /var/www/premium/web;
server_name premium.bookboon.com;
ssl_certificate /etc/ssl/certs/premium.bookboon.com_bundle.crt;
ssl_certificate_key /etc/ssl/private/premium.bookboon.com.key;
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|config|test)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_param ENVIRONMENT "prod";
}
error_log /var/log/nginx/premium_error.log;
access_log /var/log/nginx/premium_access.log;
}
任何帮助将不胜感激。
【问题讨论】:
-
这个问题似乎是off topic。
-
指定FastCGI的Nginx配置文件不是
nginx.conf。尝试发布您的/etc/nginx/sites-enabled/default文件 -
给你,希望对你有帮助,干杯!
-
根据
fastcgi_pass选项,nginx正在将请求转发到你主机的9000端口,但是那里没有程序监听。您在部署中没有错过任何一步吗? -
例如,
php-fpm(debian 上的php5-fpm)或替代安装并启动在您的服务器上? nginx 只能充当前端/代理或静态文件服务器。它不能自己处理 PHP,这就是为什么你需要一些其他的服务。