我正在尝试设置我的VPS(DigitalOcean上的Ubuntu)以运行Meteor应用程序,但在处理Nginx配置时就遇到了障碍。当我尝试重新启动Nginx时,为了使其为域名加载新的.conf文件,它显示此错误:
[[emerg] 3597#0:绑定()到0.0.0.0:80失败(98:地址已在使用中]
它在日志中重复5次,并以:结尾:
[emerg] 3597#0:仍然无法绑定()
这里是Nginx主要配置(/etc/nginx/nginx.conf)的转储:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml $
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
我在可用站点或启用站点的目录中没有任何内容(包括“默认”站点,因为我的理解是流星(通过Node)将为应用提供服务,因此我们从Nginx所需的全部是虚拟的主机处理。我的应用程序名为Loyr,所以我创建了/etc/nginx/conf.d/loyr.conf:
server {
listen 80;
server_name loyr.co;
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection ‘upgrade’;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
将文件写入conf.d目录后,我使用service nginx restart重新加载配置文件,但它只显示“ [fail]。在nginx错误日志中(/ var / log /nginx/error.log),则打印以下行:
2015/04/08 15:43:02 [emerg] 4103#0:绑定()到0.0.0.0:80失败(98:地址已在使用中)2015/04/08 15:43:02 [emerg] 4103#0:bind()0.0.0.0:80失败(98:地址已在使用中)2015/04/08 15:43:02 [emerg] 4103#0:bind()到0.0.0.0:80失败(98:地址已在使用中使用)2015/04/08 15:43:02 [emerg] 4103#0:bind()到0.0.0.0:80失败(98:地址已在使用中)2015/04/08 15:43:02 [emerg] 4103#0:将bind()设置为0.0.0.0:80失败(98:地址已在使用中)2015/04/0815:43:02 [emerg] 4103#0:仍然无法绑定()
我非常感谢您能提供关于此问题的任何见解。
尝试使用netstat -lnp
确定绑定到该端口的程序。
您在端口80上还有其他运行,请使用netstat -ntlp| grep :80
查明是什么:
[root@TIAGO-TEST ~]# netstat -ntlp | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 21224/ngin
我找到了解决方案:我尚未在Meteor Up配置中设置端口3001。我需要运行mup安装程序,然后再次运行mup deploy,以将其默认值从80切换到端口3001。
查找端口80被谁使用。