在Raspberry Pi上运行Nginx

时间:2017-07-07 16:54:20

标签: nginx raspberry-pi

我目前正在尝试在Raspberry Pi上运行Node服务器。完全披露:我不了解服务器,我是界面设计师和开发人员,所以命令行对我来说是未知的,不需要先验知识。

我尝试按照许多安装Nginx的说明进行操作,但现在它失败了,我无法指向可以查看失败位置的行。

Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.

journalctl -xn说没有文件,另一个给我详细信息,但我无法做出正面或反面:

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Fri 2017-07-07 12:43:36 EDT; 38s ago
  Process: 1071 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

我遵循了一条指示说它最好复制sites-available/default而不是编辑它,这就是我所做的:

server {
  listen 80 default_server;
  listen [::]:80 default_server;

  root /var/www/osc-api/www;

  index index.html; 

  server_name _;

  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
  }
}

server {
  listen 80 default_server;
  listen [::]:80 default_server;

  server_name osc-api;

  location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://127.0.0.1:3000/;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

是的,它与sites-enabled符号链接。我想我正在寻找有关如何解决此问题的信息。

1 个答案:

答案 0 :(得分:1)

请确认apache或其他进程未使用端口80。 请看这个链接 Nginx multiple server blocks listening to same port