运行
sudo nginx
命令后出现此错误
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
nginx: [emerg] bind() to [::]:80 failed (98: Unknown error)
nginx: [emerg] still could not bind()
在我的 Django 项目中,我为 nginx 创建了一个配置文件:(nginx.conf) (我还使用
uwsgi
作为第二个运行良好的网络服务器)
# the upstream components nginx needs to connect to
upstream dcohort {
server unix:///tmp/dcohort.sock;
}
server {
listen 80;
listen [::]:80;
server_name *.amazonaws.com;
access_log off;
error_log /home/ubuntu/dcohort/logs/nginx_error.log;
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass dcohort;
}
}
然后将配置导入到
/etc/nginx/nginx.conf
http {
include /home/ubuntu/dcohort/config/nginx.conf;
# ...
}
您检查过/etc/nging/sites-enabled吗?它包含指向可用站点的链接,通常是由于您的配置冲突引起的错误,例如在不同的配置中多次使用端口 80,您应该删除或更新其中一个端口