why do nginx process run with user nobody
Solution 1
Is there a reason why they are not running as www-data ?
Yes. You most likely haven't specified the user in your nginx config.
User Directive: http://nginx.org/en/docs/ngx_core_module.html#user
syntax: user user [group];
default:
user nobody nobody;
context: main
How to run nginx as a particular user?
You can specify the user/group that nginx runs as, in the nginx config.
This is an example of what an nginx config might look like (notice the user directive):
pid /path/to/nginx.pid;
user www-data www-data;
worker_processes 1;
events {
worker_connections 1024; # usually 1024 is a good default
}
http {
# more code goes here
}
Simply update your config and then reload or restart nginx and you should be good to go.
Of course you should choose the user that works best for your system, in Debian/Ubuntu there's a www-data by default, so that's a sensible choice.
Solution 2
The master process is run as root, then nginx will setuid()
/setgid()
to USER
/GROUP
. If GROUP
is not specified, then nginx uses the same name as USER
.
By default it's nobody
user and nobody
or nogroup group or the --user=USER
and --group=GROUP
from the ./configure
script.
You can edit nginx.conf and set user to www www;
Related videos on Youtube
RedHawkDK
Updated on September 18, 2022Comments
-
RedHawkDK over 1 year
I'm trying to make a Launch Configuration for my AWS Cloud Environment.
I wan't to install httpd and start it up on the fly, when the autoscaling group spins up a new EC2 instance.
I can SSH into the instance manually and install httpd with: sudo yum update -y sudo yum install httpd -y sudo service httpd start
But I can't make it happen, with the Launch Configuration under Advance Details -> User Data sudo yum update -y sudo yum install httpd -y sudo service httpd start
Any ideas why it's not the same?
Update After adding
#!/bin/bash
as @Mark-B suggested, then service is kindda installed. It gives the following error when restarting the service. Maybe it could be a hint for you, to figure out what is wrong? -
binaryanomaly over 9 yearswww-data is to my understanding rather the owner/group of /var/www and it's not a good idea to use the same user for the nginx process (stackoverflow.com/questions/22336186/…) A fresh installation of nginx via apt on debian uses the user nginx. Maybe you'd want to change the example to using the nginx user.
-
RedHawkDK over 5 yearsHi Mark. That makes sense! Thanks. Any ideas, why the server still isn't starting up the same way, as when I start it up manually? sudo service httpd status --- > httpd (pid 2734) is running... so it apparently looks fine...
-
Mark B over 5 years@RedHawkDK that second issue looks like a duplicate of this: stackoverflow.com/questions/5856205/…