nginx服务器无法使用服务重新启动nginx start [英] nginx server cannot restart using service nginx start

查看:546
本文介绍了nginx服务器无法使用服务重新启动nginx start的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的错误.日志

2016/07/01 07:38:17 [emerg] 30759#0: getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
2016/07/01 07:48:02 [emerg] 30806#0: getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
2016/07/01 07:48:44 [emerg] 30832#0: getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
2016/07/01 08:07:36 [emerg] 30913#0: getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
2016/07/01 08:07:44 [emerg] 30939#0: getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
2016/07/01 08:07:49 [emerg] 30964#0: getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
2016/07/01 08:13:54 [emerg] 31138#0: getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
2016/07/01 09:52:49 [emerg] 31735#0: getpwnam("nginx") failed

这是我的nginx.conf

And this is my nginx.conf

worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    include /etc/nginx/conf.d/*.conf;
    server {
    listen       80 default_server;
    listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
        include /etc/nginx/default.d/*.conf;
        location / {
        }
    error_page 404 /404.html;
            location = /40x.html {
        }

    error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}

推荐答案

如果要从源代码编译Nginx,则可能在编译时指定了用户和组标志.

If you’re compiling Nginx from source, you might be specifying the user and group flags at compile time.

在这种情况下,您需要确保尝试启动Nginx时用户确实存在.

If this is the case, you need to ensure that the users actually exist when you attempt to start Nginx.

如何修复getpwnam("nginx")失败

How to fix getpwnam("nginx") failed

解决此问题很容易,只需发出以下命令即可创建指定的用户(在本例中为"nginx"):

It’s easy to fix this issue, simply create the specified user (in this case, ‘nginx’) by issuing the following command:

useradd nginx

如果您希望创建没有主目录的用户,只需添加--no-create-homeflag,如下所示:

If you would prefer to create the user without a home directory, just add the --no-create-homeflag, as such:

useradd --no-create-home nginx

这篇关于nginx服务器无法使用服务重新启动nginx start的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆