我试图设置我的VPS(DigitalOcean上的Ubuntu)来运行Meteor应用程序,但是在处理Nginxconfiguration时遇到了一些麻烦。 当我尝试重新启动Nginx时,为了为一个域名加载一个新的.conf文件,它显示了这个错误:
[emerg] 3597#0:绑定()到0.0.0.0:80失败(98:地址已经在使用)
它在日志中重复5次,结束于:
[emerg] 3597#0:仍然无法绑定()
这是Nginx主configuration(/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/*; }
我没有任何东西在网站的可用或网站启用的目录(包括一个“默认”的网站),因为我的理解是,meteor(通过节点),而不是服务的应用程序,所以我们需要从Nginx的虚拟主机处理。 我的应用程序的名字是Loyr,所以我创build了/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目录之后,我使用nginx重新启动服务来重新加载configuration文件,但是它只是说“[失败]。在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:绑定()到0.0.0.0:80失败(98:地址已经在使用)2015/04/08 15:43:02 [emerg] 4103#0:绑定()到0.0.0.0:80失败(98:地址已经在使用)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:仍然无法绑定()
我真的很感谢你在这个问题上给我的任何见解。
尝试使用netstat -lnp
来确定绑定到该端口的程序。
你还有其他东西在80端口上运行,使用netstat -ntlp| grep :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 setup&mup deploy从默认值80切换到3001端口。之后,工作。