加入收藏 | 设为首页 | 会员中心 | 我要投稿 商洛站长网 (https://www.0914zz.com/)- AI应用、CDN、边缘计算、云计算、物联网!
当前位置: 首页 > 运营中心 > Nginx > 正文

解决新Nginx安装问题的步骤

发布时间:2020-09-05 11:05:04 所属栏目:Nginx 来源:互联网
导读:我在运行Ubuntu 12.04的新服务器上设置Nginx.这是我到目前为止所做的:已安装的nginx:aptitude -y install nginx 删除了默认的vhost配置:rm /etc/nginx/sites-enabled/* 添加了我自己的vhost配置:mv myapp.conf /etc/nginx/sites-

我在运行Ubuntu 12.04的新服务器上设置Nginx.这是我到目前为止所做的:

>已安装的nginx:

aptitude -y install nginx

>删除了默认的vhost配置:

rm /etc/nginx/sites-enabled/*

>添加了我自己的vhost配置:

mv myapp.conf /etc/nginx/sites-enabled/

>开始使用nginx:

service nginx start

vhost文件看起来像这样:

upstream unicorn_server {
  server unix:/tmp/APP_NAME.sock fail_timeout=0;
}

server {
  listen 80 default deferred;
  client_max_body_size 4G;
  server_name _;
  keepalive_timeout 5;
  access_log  /var/log/nginx/APP_NAME.access.log;

  root /var/www/APP_NAME/current/public;

  # auth

  try_files $uri/index.html $uri.html $uri @app;

  location @app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    # proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://unicorn_server;
  }

  error_page 500 502 503 504 /500.html;
  location = /500.html {
    root /var/www/APP_NAME/current/public;
  }
}

我可以确认Nginx正在运行:

service nginx status
 * nginx is running

但是,我似乎无法访问它:

curl 123.456.789.0 # example IP
curl: (7) couldn't connect to host

我还没有启动unicorn服务器,但这应该不是问题.如果Unicorn没有运行,我希望看到502错误.错误或访问日志中没有输出.我应该采取哪些措施来解决问题? 最佳答案 >在配置文件上运行nginx -t
>检查日志文件 – 你指定的文件和nginx写的可能的“默认”文件,如果它不能使用指定的文件,在加载配置之前,或者它是否感觉像,当然还有可能包含错误消息的全局日志
>停止nginx,并手动启动它(即不使用init脚本)并查找输出.杀死你的nginx然后使用init脚本启动它.
>检查netstat是否显示nginx监听.如果没有,请不要打扰测试是否可以到达,找到原因.如果它正在侦听,请在本地测试它(wget)以查明nginx或连接是否被破坏.
>如果它没有受伤(即机器上没有其他任何东西),请尝试重新启动它.

(编辑:商洛站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读