2016-03-08 125 views
11

我遇到了一个问题,我一直试图修复几天,我不知道该怎么做,一直在寻找答案,但是我发现的所有问题都没有解决,帮助我。nginx未启动,无法启动

我在这里有点新,我真的希望有人能帮助我。 你可以告诉我需要提供哪些信息,希望找到解决方案。

$ systemctl status nginx.service 
nginx.service - Startup script for nginx service 
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) 
    Active: failed (Result: exit-code) since Tue 2016-03-08 13:23:35 GMT; 2min 20s ago 

Mar 08 13:23:33 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ------------ f...e) 
Mar 08 13:23:33 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e) 
Mar 08 13:23:34 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e) 
Mar 08 13:23:34 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e) 
Mar 08 13:23:35 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e) 
Mar 08 13:23:35 .startdedicated.com nginx[8315]: nginx: [emerg] still could not bind() 
Mar 08 13:23:35 startdedicated.com systemd[1]: nginx.service: control process exited, code=...=1 
Mar 08 13:23:35 startdedicated.com systemd[1]: Failed to start Startup script for nginx service. 
Mar 08 13:23:35 startdedicated.com systemd[1]: Unit nginx.service entered failed state. 
Mar 08 13:23:35 startdedicated.com systemd[1]: nginx.service failed. 
+0

请发布您的nginx.conf和:“nginx -t”输出... – user2925795

+0

http://prntscr.com/acoayr 这就是它。我不能发布代码,所以我不得不截图。 – daliborsb

+0

请发布您的服务器块配置和:“nginx -t”输出...您是否尝试重新启动nginx? “服务nginx的重启” – user2925795

回答

0

尝试设置在nginx.conf用户,也许这就是为什么他不能启动服务:

User www-data; 
+0

我应该用“User = www-data”添加一个新行吗? – daliborsb

+0

在你的nginx.conf中。第一行的printscreen是用户nginx;删除#并把用户www-data; – user2925795

+0

http://prntscr.com/acoqd8 同样的事情。我尝试过,但它不再工作。 – daliborsb

9

尝试用命令来调试:

$ service nginx configtest 

它输出像:

Testing nginx configuration: nginx: [emerg] unknown directive "stub_status" in /etc/nginx/sites-enabled/nginx_status:11 
nginx: configuration file /etc/nginx/nginx.conf test failed 

并修复这些警告

然后重启nginx的

+1

这将是需要尝试的最佳方法之一,谢谢 – GPrathap

+12

**测试nginx配置:失败! ** –

18

可能会派上用场运行检查的Nginx的配置文件中的语法:

nginx -t -c /etc/nginx/nginx.conf 
+0

在我的情况下,它可以与'sudo/usr/local/nginx/sbin/nginx -t -c/usr/local/nginx/conf/nginx.conf'或者'sudo/usr/local/nginx/sbin/nginx -t' – Pathros

-4
  • 使用这些命令

    1. sud O服务的Apache2停止

    2. sudo易于得到净化的Apache2

    3. sudo易于得到更新

    4. 命令和apt-get安装nginx的

    5. sudo的服务nginx的重新启动

+10

更多解释会使这个更好的答案。 – CGritton

1

当某些东西不能绑定到一个端口,它是5%,因为它不是由根(粘性suid位,sudo)启动的,94%是因为另一个应用程序已经绑定到该端口。

确保nginx真正关闭,并且您不会偶然启动它两次。

确保你没有Apache或其他服务运行使用80端口

利用netstat -a | grep tcp以了解更多信息。

1

当我使用了使用nginx和apache的Vesta时,我遇到了同样的问题。问题是,在应用所有更新后,Apache开始为https收听443。解决方案只是在ports.conf中注释掉443个东西。这是因为nginx也使用这个端口。

0

我使用RHEL 7.4和NGINX 1.13。8,如果我做同样的使用sudo,它的工作原理确定:

sudo systemctl status nginx.service 

只要确保谁想用nginx.service具有执行权限给它。