- nginx starts with root permissions
- that's because any process that requires to run below port
1024
needs elevated privileges - The TCP/IP port numbers below
1024
are special in that normal users are not allowed to run servers on them. This is a security feaure, in that if you connect to a service on one of these ports you can be fairly sure that you have the real thing, and not a fake which some hacker has put up for you.
- but then the trouble arrives when nginx wants to limit the privileges (because, an unrestricted process can do a lot of damage, and this is why
deno
doesn't even have file systems permissions when it starts) - this is why nginx spawns several child processes
- the number of child processes is determined by the number(integer) mentioned against
worker_processes
, which in my case (default) is set toworker_processes auto;
andauto
is what you do when you do not know or do not want to know the number of CPU cores on the machine - Count the number of CPU cores on thy machine:
grep processor /proc/cpuinfo | wc -l
- the child processes are created with the username provided aginst the following field:
user www-data;
- so, after starting your nginx (e.g. say, by doing a
sudo systemctl start nginx
), you can check for the list of spawned child processes by executingps aux | grep nginx
in the terminal
- The following file will contain the process id for nginx so that you don't have to do a lot of manual mish-mashing
pid /run/nginx.pid;
- so, just
cat /run/nginx.pid;
whenever you feel like - To see the master process:
ps aux | grep nginx
nginx
has two types of directives
- context directives e.g.
events
,http
- simple directives e.g.
worker_connections