Starting and stopping Nginx

In the previous chapter, you learned a bit about how to start your Nginx instance. On Ubuntu, Debian, or Redhat-like systems you can run the following command:

# service nginx start

In the absence of startup scripts, you can simply run the binary using the following command:

# sbin/nginx

Nginx will read and parse the configuration file, create a PID file (a file containing its process ID), open log files, create listening sockets, and start worker processes. Once worker processes have started, a Nginx instance is able to respond to incoming connections. This is what a running Nginx instance looks like in the process list:

# ps -C nginx -f
UID        PID  PPID  C STIME TTY          TIME CMD
root 2324 1 0 15:30 ? 00:00:00 nginx: master ...

Get Nginx Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.