gpt4 book ai didi

django - 无法重启nginx

转载 作者:行者123 更新时间:2023-12-03 22:52:34 25 4
gpt4 key购买 nike

我在 Ubunto 10:04 上使用 nginx 和 Django。问题是当我重新启动 nginx 时出现此错误。

sudo /etc/init.d/nginx restart
Restarting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

另外,我尝试停止然后启动,但仍然出现错误。

这是 lsof 的输出:
sudo lsof -i tcp:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 27141 root 6u IPv4 245906 0t0 TCP *:www (LISTEN)
nginx 27142 nobody 6u IPv4 245906 0t0 TCP *:www (LISTEN)

如果我用 PID 27141 终止进程,它就可以工作。但是,我想深入了解
为什么我不能只是重新启动。

这是 nginx.conf:
worker_processes 1;

user nobody nogroup;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;

events {
worker_connections 1024;
accept_mutex off;
}

http {
include mime.types;
default_type application/octet-stream;
access_log /tmp/nginx.access.log combined;
sendfile on;

upstream app_server {
# server unix:/tmp/gunicorn.sock fail_timeout=0;
# For a TCP configuration:
server 127.0.0.1:8000 fail_timeout=0;
}

server {
listen 80 default;
client_max_body_size 4G;
server_name _;

keepalive_timeout 5;

# path for static files
root /home/apps/venvs/app1/app1;

location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}

location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

proxy_pass http://app_server;
}

error_page 500 502 503 504 /500.html;
location = /500.html {
root /path/to/app/current/public;
}
}
}

有任何想法吗?

最佳答案

尝试:

$ sudo fuser -k 80/tcp ; sudo /etc/init.d/nginx restart 

关于django - 无法重启nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6083109/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com