首页 文章

我的NIGINX服务器已关闭 . 我该如何重新启动它?我是NGINX和CentOS的新手

提问于
浏览
0

这是我的NGINX配置文件:

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        location / {
            root  /usr/share/nginx/html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

当我在终端中键入 service nginx start 时,它显示:

Redirecting to /bin/systemctl start nginx.service
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

当我执行 systemctl status nginx.service 时,它显示:

systemctl status nginx.service
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2016-06-29 10:17:58 EDT; 10s ago
Process: 21459 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 21457 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14307 (code=exited, status=0/SUCCESS)

Jun 29 10:17:58 lotto systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jun 29 10:17:58 lotto nginx[21459]: nginx: [emerg] unexpected end of file, expecting "}" in /etc/ng...f:80
Jun 29 10:17:58 lotto nginx[21459]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jun 29 10:17:58 lotto systemd[1]: nginx.service: control process exited, code=exited status=1
Jun 29 10:17:58 lotto systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jun 29 10:17:58 lotto systemd[1]: Unit nginx.service entered failed state.
Jun 29 10:17:58 lotto systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

i install nginx in my remote server
但我在我的nginx.conf文件中做了一些错误,无法恢复,所以它试图删除我的nginx并重新配置它,所以我使用链接中给出的这些步骤来删除我的nginx http://www.ehowstuff.com/how-to-remove-uninstall-nginx-on-centos-7-rhel-7-oracle-linux-7/ then i use yum remove nginx and again reinstall it
但当我尝试 sudo systemctl start nginx or [root@lotto nginx]# service nginx start
它的表现

nginx.service的作业失败,因为控制进程的exitenter代码中包含错误代码 . 有关详细信息,请参见"systemctl status nginx.service"和"journalctl -xe" . when i am using [root@lotto nginx]# systemctl status nginx.service showing

nginx.service - nginx HTTP和反向代理服务器已加载:已加载(/usr/lib/systemd/system/nginx.service;已启用;供应商预设:已禁用)活动:自2016-07 Fri以来失败(结果:退出代码) -01 07:48:44 EDT; 18s ago Process:30832 ExecStartPre = / usr / sbin / nginx -t(code = exited,status = 1 / FAILURE)进程:30830 ExecStartPre = / usr / bin / rm -f /run/nginx.pid(code = exited, status = 0 / SUCCESS)主PID:14307(代码=退出,状态= 0 /成功)

Jul 01 07:48:44 lotto systemd [1]:启动nginx HTTP和反向代理服务器... Jul 01 07:48:44 lotto nginx [30832]:nginx:[emerg] getpwnam(“nginx”)失败/etc/nginx/nginx.conf:5 Jul 01 07:48:44 lotto nginx [30832]:nginx:配置文件/etc/nginx/nginx.conf测试失败7月01日07:48:44 lotto systemd [1]: nginx.service:控制进程退出,代码=退出状态= 1 Jul 01 07:48:44 lotto systemd [1]:无法启动nginx HTTP和反向代理服务器 . Jul 01 07:48:44 lotto systemd [1]:单位nginx.service进入失败状态 . Jul 01 07:48:44 lotto systemd [1]:nginx.service失败了 . 和[root @ lotto nginx] #journalctl -xe

nginx.service - nginx HTTP和反向代理服务器已加载:已加载(/usr/lib/systemd/system/nginx.service;已启用;供应商预设:已禁用)活动:自2016-07 Fri以来失败(结果:退出代码) -01 07:48:44 EDT; 18s ago Process:30832 ExecStartPre = / usr / sbin / nginx -t(code = exited,status = 1 / FAILURE)进程:30830 ExecStartPre = / usr / bin / rm -f /run/nginx.pid(code = exited, status = 0 / SUCCESS)主PID:14307(代码=退出,状态= 0 /成功)

2 回答

  • 0

    错误发生在您的配置文件中 . 当我编辑你的帖子时,我不小心纠正了它,因为我认为你错误地复制了它 .

    这一行 Jun 29 10:17:58 lotto nginx[21459]: nginx: [emerg] unexpected end of file, expecting "}" in /etc/ng...f:80 正在告诉你什么时候错了 . 如果语法不是't correct, the service won' t开始 .

    } 添加到 nginx.conf 文件的末尾,它应该可以正常工作 .

  • 0

    如果您在启动nginx服务时遇到问题,请重新检查conf文件 . 您可以使用此检查配置错误

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

相关问题