9 Popular Nginx Commands You Should Know - KeyCDN Support
9 Popular Nginx Commands You Should Know - KeyCDN Support
Nginx is one of the most popular web servers in the world. So whether
youʼre currently using it or not, chances are, if youʼre a web developer
chances are youʼll likely come in contact with it at some point. Therefore
there are a few important Nginx commands you should be aware of in order
to get familiar with the basics of this web server.
I this guide weʼre going to go over what these popular Nginx commands are,
how to use them, and what each one does.
Reference the following list of popular commands if you ever need a quick
reminder on how to use a certain command or what it does. Remember, if
you arenʼt a root user, youʼll need to sudo each command in order for them
to properly work.
https://www.keycdn.com/support/nginx-commands Page 1 of 6
9 Popular Nginx Commands You Should Know - KeyCDN Support 7/12/19, 12(38
If youʼre using a systemd based version such as Ubuntu Linux 16.04LTS and
above, use systemctl within the command, like so:
Example response:
Stopping Nginx will kill all system processes quickly. This will terminate
Nginx even if there are open connections. In order to do so, run one of the
following commands:
Example response:
This command can still, however, take some time on busy servers.
Therefore, if you want Nginx to stop even faster, you can also use:
killall -9 nginx
https://www.keycdn.com/support/nginx-commands Page 2 of 6
9 Popular Nginx Commands You Should Know - KeyCDN Support 7/12/19, 12(38
Restarting Nginx basically performs a stop then a start. Use one of the
following commands to run a Nginx restart:
Example response:
Example response:
https://www.keycdn.com/support/nginx-commands Page 3 of 6
9 Popular Nginx Commands You Should Know - KeyCDN Support 7/12/19, 12(38
Check what the current status of your Nginx web server is with one of the
following commands:
Example response:
nginx is running
You can test your Nginx serverʼs configuration file before restarting or
reloading it completely. This helps prevent any unforeseen errors which can
cause your website to gown down. To do this there are two separate
commands you can use, both return the same information:
nginx -t
Example response:
There are also two different ways to check your Nginx version. Both are
https://www.keycdn.com/support/nginx-commands Page 4 of 6
9 Popular Nginx Commands You Should Know - KeyCDN Support 7/12/19, 12(38
fairly similar but one shows a little more information than the other. Use one
of the following Nginx commands to print the Nginx version:
service nginx -v
systemctl -v nginx
Use the following command to print the Nginx version, compiler version and
configure parameters.
service nginx -V
systemctl -V nginx
If youʼd like a quick reference guide of the commands available directly from
within the terminal, use one of the following help commands:
service nginx -h
systemctl -h nginx
Or:
service nginx -?
systemctl -? nginx
This Nginx commands shown in this article are a few of the most popular
ones. There do exist a few other parameters however these arenʼt used
nearly as much. Reference this guide whenever youʼre stuck for a Nginx
command and hopefully, youʼll find the one you need.
https://www.keycdn.com/support/nginx-commands Page 5 of 6
9 Popular Nginx Commands You Should Know - KeyCDN Support 7/12/19, 12(38
feature of being…
https://www.keycdn.com/support/nginx-commands Page 6 of 6