11

Im just installed nginx from source

but when run /etc/init.d/php_cgi start, there is a message:
Starting php-cgi: spawn-fcgi: can't find user name nginx

...one more I dont know about their permission.

previously I install nginx using yum (CentOS)

3 Answers3

20

This will create the user and set their shell to /bin/false so no one can start an interactive login as this user.

$ useradd -s /bin/false nginx
EEAA
  • 109,363
  • 18
  • 175
  • 245
  • 1
    can you tell me why `/bin/false`? what is `/bin/false`? my previous server also shell to `/bin/false` but I have no idea about it –  Oct 14 '10 at 13:38
  • 1
    `/bin/false` exists for one purpose - to provide a non-zero exit code. Contrast this with `/bin/true`, which always provides a zero exit code. The effect this has with regards to user accounts is that the user doesn't have a valid shell. – EEAA Oct 14 '10 at 13:50
9

Try

$ sudo adduser --system --no-create-home --user-group --disabled-login --disabled-password nginx

Or

$ sudo adduser --system --no-create-home --user-group -s /sbin/nologin nginx
Hamid
  • 202
  • 1
  • 3
  • 7
  • I get Option s is ambiguous (shell, system) (probably you want use shell) – shakaran Jan 14 '15 at 03:41
  • I think you don't need `--disabled-password` when using `--disabled-login`. According to the documentation: `--disabled-login` - Do not run passwd to set the password. The user won't be able to use her account until the password is set. `--disabled-password` - Like `--disabled-login`, but logins are still possible (for example using SSH RSA keys) but not using password authentication. – czerasz Apr 08 '15 at 10:40
  • On arch use: `sudo useradd --system --no-create-home --user-group --shell /usr/bin/nologin nginx` – JackLeEmmerdeur Mar 17 '21 at 21:18
5

On Ubuntu you can use this command:

adduser --system --no-create-home --shell /bin/false --group --disabled-login nginx
czerasz
  • 577
  • 1
  • 9
  • 14