Nginx错误与端口80

我试图让我的Django应用程序运行在VPS上,而且我根据本教程做了所有的事情,但是我得到了502错误。

我假设nginx正在监听80端口(对吗?),因为sudo netstat -nlp | grep 80 sudo netstat -nlp | grep 80投掷:

 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 892/nginx tcp6 0 0 :::80 :::* LISTEN 892/nginx unix 2 [ ACC ] STREAM LISTENING 8942 805/acpid /var/run/acpid.socket 

但是,当我inputsudo nginx似乎Nginx 听80端口…:

 `nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] still could not bind()` 

我的Nginxconfiguration:

 server { server_name 95.85.34.87; access_log off; location /static/ { alias /opt/myenv/static/; } location / { proxy_pass http://127.0.0.1:8001; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } } 

任何人都可以帮我吗?

我在netstat输出中看到的是,nginx 已经在你的系统上运行了。 在Debian或者Ubuntu等系统上,可能还有其他的* nix系统,当你安装nginx的时候,它会被安装,以便在系统启动的时候启动。 然后,当您尝试从命令行运行它时,正在运行第二个实例,该实例尝试使用与引导时启动的实例相同的端口。 在Debian或者Ubuntu系统上,你可以停止nginx开始:

 $ sudo service nginx stop $ sudo rm /etc/nginx/sites-enabled/default 

删除默认设置可防止再次启动。 该默认文件是/etc/nginx/sites-available/default的符号链接,因此如果需要,您可以轻松地重新创建它。

或者,如果要保持在启动时启动的nginx在其端口上运行,则可以使用从使用不同端口的命令行启动的nginx配置,例如:

 server { listen 3333 default_server; listen [::]:3333 default_server ipv6only=on; 

附加说明:如果你把你的站点放在/etc/nginx/sites-enabled/那么你不能从命令行启动你的nginx实例。 你只能通过sudo service nginx [...]控制nginx sudo service nginx [...]