nginx 绑定失败

nginx 绑定失败

当我运行 nginx 时,出现错误,

nginx 从 npm run scripts 启动

我运行了 npm run start-prod scripts:start-prod:有以下命令

 concurrently --no-color "uwsgi --ini build/docker/uwsgi.ini" "nginx"  "npm run render-prod"

npm run render-prod 脚本的值为“render-prod”:“babel-node node/react-render.jsx”

[email protected] start-prod /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl
> concurrently --no-color "uwsgi --ini build/docker/uwsgi.ini" "nginx"  "npm run render-prod"    
[0] [uWSGI] getting INI configuration from build/docker/uwsgi.ini    
[0] *** Starting uWSGI 2.0.15 (64bit) on [Wed Feb 14 01:10:08 2018] ***    
[0] compiled with version: 5.4.0 20160609 on 09 February 2018 02:01:25    
[0] os: Linux-4.4.0-1049-aws #58-Ubuntu SMP Fri Jan 12 23:17:09 UTC 2018    
[0] nodename: ip-10-254-3-58
[0] machine: x86_64        
[0] clock source: unix            
[0] pcre jit disabled    
[0] detected number of CPU cores: 8    
[0] current working directory: 
/home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl    
[0] writing pidfile to 
/home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl/build/docker/ntdl.pid    
[0] detected binary path: /usr/local/bin/uwsgi    
[0] setgid() to 33    
[0] setuid() to 33    
[0] chdir() to /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl    
[0] your processes number limit is 60090    
[0] your memory page size is 4096 bytes    
[0] detected max file descriptor number: 1048576    
[0] lock engine: pthread robust mutexes    
[0] thunder lock: disabled (you can enable it with --thunder-lock)    
[0] bind(): Permission denied [core/socket.c line 230]    
[1] nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored    
[1] nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)    
[0] uwsgi --ini build/docker/uwsgi.ini exited with code 1
[2]    
[2] > [email protected] render-prod /home/ubuntu/bharath/sourcecode/projects/NTDL/ntdl    
[2] > babel-node node/react-render.jsx    
[2]    
[1] nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)    
[1] nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)    
[1] nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
[2] React render server listening at http://0.0.0.0:9009
[1] nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
[1] nginx: [emerg] still could not bind()
[1] nginx exited with code 1

请帮我修复这个 nginx 绑定错误。

短暂性脑缺血发作,

谨致问候,Bharath AK

答案1

其他一些进程已在监听端口 80。这可能意味着您已有一个 Apache 进程正在运行。

您可以使用此建议的命令来找出可能正在监听该端口的内容:

sudo lsof -i :80 | grep LISTEN

注意:在极少数情况下,可能存在单独的 nginx 正在监听该端口,例如,如果您手动启动了 nginx 守护程序(不推荐)或者您修改了 nginx 运行的用户(不推荐)。不过,更有可能的是,其他应用程序正在监听该端口。

Ubuntu 允许您同时安装两个 Web 服务器,因为可以将它们配置为监听不同的端口。如果不这样做,其中一个或另一个服务器将无法启动。

答案2

正如 @thomasrutter 所说,检查使用的端口sudo lsof -i -P -n并检查在哪里port 80使用。如果不需要该进程,请终止该进程并nginx再次使用检查配置sudo nginx -t。另一件事是您想在浏览器上检查您的页面,然后在运行您的页面后,您可以编辑服务器块nginx.confsites-available/default块,您可以将您的页面代理传递address:port到其中,port 80这样您只需点击端口的公共 IP 地址,然后您就可以在浏览器上看到该页面。

相关内容