无法启动 Nginx:此处不允许 "server" 指令
Can't Start Nginx: "server" directive is not allowed here
我正在尝试获取 passenger + nginx 实例 运行。 Passenger 已成功安装,但是,当转到 http://lakemagazine.northcentralus.cloudapp.azure.com/ 时,我们收到超时错误。于是,我看了看nginx:
garrett@lakemag:~$ sudo nginx -t
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:65
nginx: configuration file /etc/nginx/nginx.conf test failed
因此,nginx 不是 运行,我认为这是我的问题。
这是我的 nginx.conf 文件:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# 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;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# 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/javascript text/xml applic$
##
# Virtual Host Configs
##
#include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
server {
listen 80;
server name http://lakemagazine.northcentralus.cloudapp.azure.com/;
root /lakemag/public;
passenger_enabled on;
passenger_ruby /home/garrett/.rvm/gems/ruby-2.3.0/wrappers/ruby;
}
}
第 65 行是我的服务器 {} 块开始的地方。我对我的问题不知所措 - 所有的块似乎都对我进行了适当的定义。我错过了什么吗?
*编辑:
garrett@lakemag:~$ sudo nginx -t
[sudo] password for garrett:
nginx: [warn] server name "http://lakemagazine.northcentralus.cloudapp.azure.com/" has suspicious symbols in /etc/nginx/nginx.conf:65
nginx: [emerg] unknown directive "passenger_enabled" in /etc/nginx/nginx.conf:69
nginx: configuration file /etc/nginx/nginx.conf test failed
在 Jorge 的解决方案之后,我现在收到上述错误。
哪里说:
server name http://lakemagazine.northcentralus.cloudapp.azure.com/
应该说:
server_name http://lakemagazine.northcentralus.cloudapp.azure.com/
server
是定义服务器块并确定服务器的指令,您应该在其中写入 server_name
指令
http://nginx.org/en/docs/http/server_names.html
要检查配置文件语法,请使用:
nginx -t
我正在尝试获取 passenger + nginx 实例 运行。 Passenger 已成功安装,但是,当转到 http://lakemagazine.northcentralus.cloudapp.azure.com/ 时,我们收到超时错误。于是,我看了看nginx:
garrett@lakemag:~$ sudo nginx -t
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:65
nginx: configuration file /etc/nginx/nginx.conf test failed
因此,nginx 不是 运行,我认为这是我的问题。
这是我的 nginx.conf 文件:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# 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;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# 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/javascript text/xml applic$
##
# Virtual Host Configs
##
#include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
server {
listen 80;
server name http://lakemagazine.northcentralus.cloudapp.azure.com/;
root /lakemag/public;
passenger_enabled on;
passenger_ruby /home/garrett/.rvm/gems/ruby-2.3.0/wrappers/ruby;
}
}
第 65 行是我的服务器 {} 块开始的地方。我对我的问题不知所措 - 所有的块似乎都对我进行了适当的定义。我错过了什么吗?
*编辑:
garrett@lakemag:~$ sudo nginx -t
[sudo] password for garrett:
nginx: [warn] server name "http://lakemagazine.northcentralus.cloudapp.azure.com/" has suspicious symbols in /etc/nginx/nginx.conf:65
nginx: [emerg] unknown directive "passenger_enabled" in /etc/nginx/nginx.conf:69
nginx: configuration file /etc/nginx/nginx.conf test failed
在 Jorge 的解决方案之后,我现在收到上述错误。
哪里说:
server name http://lakemagazine.northcentralus.cloudapp.azure.com/
应该说:
server_name http://lakemagazine.northcentralus.cloudapp.azure.com/
server
是定义服务器块并确定服务器的指令,您应该在其中写入 server_name
指令
http://nginx.org/en/docs/http/server_names.html
要检查配置文件语法,请使用:
nginx -t