nginx - 我的 NGINX 服务器已关闭。如何重新启动它?我对 NGINX 和 CentOS 还很陌生

标签 nginx centos

这是我的 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 的作业失败,因为控制进程退出输入代码带有错误代码。有关详细信息,请参阅“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 年 7 月 1 日 07:48:44 以来失败(结果:退出代码); 18 秒前 进程: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/成功)

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

nginx.service - nginx HTTP 和反向代理服务器
已加载:已加载(/usr/lib/systemd/system/nginx.service;已启用;供应商预设:已禁用)
事件:自美国东部时间周五 2016 年 7 月 1 日 07:48:44 以来失败(结果:退出代码); 18 岁前
进程: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/成功)

最佳答案

错误在您的配置文件中。我在编辑您的帖子时不小心更正了它,因为我认为您复制错误。

此行Jun 29 10:17:58 lotto nginx[21459]: nginx: [emerg] unexpected end of file, expecting "}" in /etc/ng...f:80准确地告诉你什么时候出错了。如果语法不正确,服务将不会启动。

添加 }到您的 nginx.conf 结尾文件,它应该可以工作。

关于nginx - 我的 NGINX 服务器已关闭。如何重新启动它?我对 NGINX 和 CentOS 还很陌生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38102721/

相关文章:

apache - nginx 将所有域重定向到另一个端口,但为管理应用程序保留一个域

angular - 将docker镜像部署到GAE以获得 Angular

python - 如何在 Python3 上安装 Bob?

bash - 如何使用 curl --ftp-create-dirs?

docker-storage-setup 包在我的 rhel 7 盒子上不可用?我怎么得到它?我需要使用设备映射器创建一个精简池。

django - UWSGI套接字更改组并拒绝连接,导致502错误的网关

nginx - 将 nginx access_log 和 error_log 记录到 master 进程的 STDOUT 和 STDERR

ruby-on-rails - 在 Rails 中使用 unicorn、nginx 和 capistrano 设置虚拟主机

python - 在 CentOS 中以 root 身份运行 python3