7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
Menu
Menu
10 Most Used Nginx Commands Every Linux User
Must Know
Aaron Kili Last Updated: April 23, 2019 Nginx 11 Comments
Nginx (pronounced Engine x) is a free, open-source, high-performance, scalable, reliable,
full-featured and popular HTTP and reverse proxy server, a mail proxy server, and a
generic TCP/UDP proxy server.
Nginx is well known for its simple configuration, and low resource consumption due to its
high performance, it is being used to power several high-traffic sites on the web, such as
GitHub, SoundCloud, Dropbox, Netflix, WordPress and many others.
Read Also: 3 Useful Hacks Every Linux User Must Know
Ad
AD
vivo V21 Be The Light at Night
In this guide, we will explain some
vivoof the most commonly used Nginx service
Bangladesh
management commands that, as a developer or system administrator, you should
SHOPkeep
NOW
at your fingertips. We will show commands for both Systemd and SysVinit.
https://www.tecmint.com/useful-nginx-command-examples/ 1/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
All of these following list of Nginx popular commands must be executed as a root or
sudo user and should work on any modern Linux distribution such as CentOS, RHEL,
Debian, Ubuntu and Fedora.
Install Nginx Server
To install Nginx web server, use your default distribution package manager as shown.
$ sudo yum install epel-release && yum install nginx [On CentOS/RHEL]
$ sudo dnf install nginx [On Debian/Ubunt
$ sudo apt install nginx [On Fedora]
Check Nginx Version
To check the version of Nginx web server installed on your Linux system, run the
following command.
$ nginx -v
nginx version: nginx/1.12.2
The above command simply displays the version number. If you want to view version and
configure options then use the -V flag as shown.
Ad
AD $ nginx -V
vivo V21 Be The Light at Night
vivo Bangladesh
SHOP NOW
Show Nginx, Compiler and Configuration Parameters
https://www.tecmint.com/useful-nginx-command-examples/ 2/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
nginx version: nginx/1.12.2
RedHat
built RHCSA
by gcc and RHCE
4.8.5 Certification
20150623 (Red HatPreparation
4.8.5-16)Guide -
(GCC) Get This Book
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/ng
Check Nginx Configuration Syntax
Before you actually start the Nginx service, you can check whether its configuration
syntax is correct. This is especially useful if you have made changes or added a new
configuration to the existing configuration structure.
To test the Nginx configuration, run the following command.
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
You can test the Nginx configuration, dump it and exit using the -T flag as shown.
$ sudo nginx -T
Show Nginx Configuration Settings
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Ad
AD nginx: configuration file /etc/nginx/nginx.conf test is successful
vivo V21 Be The Light at Night
# configuration file /etc/nginx/nginx.conf:
vivo Bangladesh
# For more information on configuration, see:
SHOP NOW
# * Official English Documentation: http://nginx.org/en/docs/
https://www.tecmint.com/useful-nginx-command-examples/ 3/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$requ
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d direc
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
Ad
AD
include /etc/nginx/conf.d/*.conf;
vivo V21 Be The Light at Night
vivo Bangladesh
server {
SHOP NOW
listen 80 default_server;
https://www.tecmint.com/useful-nginx-command-examples/ 4/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
....
Start Nginx Service
To start the Nginx service, run the following command. Note that this process may fail if
the configuration syntax is not OK.
$ sudo systemctl start nginx #systemd
OR
$ sudo service nginx start #sysvinit
Ad
AD
vivo V21 Be The Light at Night
Enable Nginx Service vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 5/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
The previous command only starts the service for the meantime, to enable it auto-start
at boot time, run the following command.
$ sudo systemctl enable nginx #systemd
OR
$ sudo service nginx enable #sysv init
Restart Nginx Service
To restart the Nginx service, an action which will stop and then start the service.
$ sudo systemctl restart nginx #systemd
OR
$ sudo service nginx restart #sysv init
View Nginx Service Status
You can check the Nginx service’s status as follows. This command shows the run time
status information about the service.
$ sudo systemctl status nginx #systemd
OR
$ sudo service nginx status #sysvinit
Show Nginx Status Information
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.
Ad
AD
[root@tecmint ~]# systemctl status
vivo V21 nginx
Be The Light at Night
vivo Bangladesh
● nginx.service - The nginx HTTP and reverse proxy server
SHOP NOW
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled;
vend
Active: active (running) since Tue 2019-03-05 05:27:15 EST; 2min 59s
https://www.tecmint.com/useful-nginx-command-examples/ 6/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
Main PID: 31515 (nginx)
CGroup: /system.slice/nginx.service
├─31515 nginx: master process /usr/sbin/nginx
└─31516 nginx: worker process
Mar 05 05:27:15 tecmint.com systemd[1]: Starting The nginx HTTP and rev
Mar 05 05:27:15 tecmint.com nginx[31509]: nginx: the configuration file
Mar 05 05:27:15 tecmint.com nginx[31509]: nginx: configuration file /et
Mar 05 05:27:15 tecmint.com systemd[1]: Failed to read PID from file /r
Mar 05 05:27:15 tecmint.com systemd[1]: Started The nginx HTTP and reve
Reload Nginx Service
To tell Nginx to reload its configuration, use the following command.
$ sudo systemctl reload nginx #systemd
OR
$ sudo service nginx reload #sysvinit
Stop Nginx Service
If you want to stop the Nginx service for once reason or the other, use the following
command.
$ sudo systemctl stop nginx #systemd
OR
$ sudo service nginx stop #sysvinit
Ad
AD
vivo V21 Be The Light at Night
Show Nginx Command Help vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 7/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
To get an easy reference guide of all Nginx commands and options, use following
command.
$ systemctl -h nginx
Nginx Help Commands and Options
systemctl [OPTIONS...] {COMMAND} ...
Query or send control commands to the systemd manager.
-h --help Show this help
--version Show package version
--system Connect to system manager
-H --host=[USER@]HOST
Operate on remote host
-M --machine=CONTAINER
Operate on local container
-t --type=TYPE List units of a particular type
--state=STATE List units with particular LOAD or SUB or ACTIVE
-p --property=NAME Show only properties by this name
-a --all Show all loaded units/properties, including dead/
ones. To list all units installed on the system,
the 'list-unit-files' command instead.
-l --full Don't ellipsize unit names on output
-r --recursive Show unit list of host and local containers
--reverse Show reverse dependencies with 'list-dependencies
--job-mode=MODE Specify how to deal with already queued jobs, whe
queueing a new job
--show-types When showing sockets, explicitly show their type
-i --ignore-inhibitors
Ad
AD
... vivo V21 Be The Light at Night
vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 8/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
You might also like to read these following Nginx related articles.
The Ultimate Guide to Secure, Harden and Improve Performance of Nginx Web
Server
Amplify – NGINX Monitoring Made Easy
ngxtop – Monitor Nginx Log Files in Real Time in Linux
How to Install Nginx with Virtual Hosts and SSL Certificate
How to Hide Nginx Server Version in Linux
That’s all for now! In this guide, we have explained some of the most commonly used
Nginx service management commands that you should know, including starting,
enabling, restarting and stopping Nginx. If you have any additions or questions to ask,
use the feedback form below.
Nginx Tips
Installation of Ubuntu 19.04 (Disco How to Change User Password in Ubuntu
Dingo) Desktop on UEFI Firmware Systems
If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have
any questions or doubts? do ask for help in the comments section.
Ad
AD
vivo V21 Be The Light at Night
vivo Bangladesh
SHOP NOW
If You Appreciate What We Do Here On TecMint, You
Ad
AD
Should
vivo V21 Be TheConsider:
Light at Night
vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 9/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
TecMint is the fastest growing and most trusted community site for
any kind of Linux Articles, Guides and Books on the web. Millions of
people visit TecMint! to search or browse the thousands of published
articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee (
or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Related Posts
Ad
AD
vivo V21 Be The Light at Night
How to Install LEMP Stack on Rocky Linux 8
vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 10/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
How to Speed Up Nginx with Varnish Cache on CentOS 7
How To Prevent PHP-FPM From Consuming Too Much RAM in Linux
Ad
AD
vivo V21 Be The Light at Night
vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 11/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
GoAccess (A Real-Time Apache and Nginx) Web Server Log Analyzer
How to Install, Run and Delete Applications Inside Docker Containers – Part 2
Ad
AD
vivo V21 Be The Light at Night
vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 12/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
How to Set Up Nginx Server Blocks (Virtual Hosts) on CentOS 8
11 thoughts on “10 Most Used Nginx Commands
Every Linux User Must Know”
Tomba
July 28, 2020 at 6:12 pm
$ sudo dnf install nginx [On Debian/Ubuntu]
$ sudo apt install nginx [On Fedora]
Reply
Raghu
January 30, 2020 at 6:38 am
Nice article.
Ad
AD
vivo V21 Be The Light at Night
vivo Bangladesh
How did you get your Nginx installed with OpenSSL-fips? Did you specify any
SHOP NOW
FLAGS in environment variables?
https://www.tecmint.com/useful-nginx-command-examples/ 13/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
Reply
Aaron Kili
January 30, 2020 at 2:34 pm
@Raghu
The package in the official repositories of most if not all Linux distributions
comes pre-compiled with OpenSSL-fips.
Reply
Dinesh
January 25, 2020 at 10:31 am
I installed nginx on ubuntu 16.04 and configure sites available and sites enabled
but my laravel application is not running to the server name (http://local.test)
which I have provided.
Reply
Aaron Kili
January 27, 2020 at 3:15 pm
Ad
AD
@Dinesh vivo V21 Be The Light at Night
vivo Bangladesh
Have you checked the Nginx error logs? If you are running it locally, you need
SHOPto
NOW
enter an entry in /etc/hosts file. Check out this guide to learn how to use
https://www.tecmint.com/useful-nginx-command-examples/ 14/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
/etc/hosts file for local DNS: https://www.tecmint.com/setup-local-dns-using-
etc-hosts-file-in-linux/
Reply
Skippy
December 17, 2019 at 1:48 am
The very top box (how to install Nginx) has Debian/Ubuntu and Fedora flipped.
Reply
Tiago
September 5, 2019 at 11:19 am
Thanks bro!
I was able to solve, through these tips, error 521 in CloudFlare. The site was
down for 3 days.
Thank you)
Reply
Ad
AD
vivo V21 Be The Light at Night
Lasse vivo Bangladesh
April 23, 2019 at 7:11 pm
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 15/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
This whole article has literally nothing to do with nginx, it reads more like a
systemd tutorial.
Reply
Aaron Kili
April 25, 2019 at 10:19 am
@Lasse
You are right, as you can see, we have zeroed down to the Nginx service
management though. Many thanks for the useful feedback.
Reply
Oli
April 23, 2019 at 5:07 pm
This article looks mostly like an introduction to systemd’s systemctl. And the last
command doesn’t even show the “Nginx Command Help”, it’s the help of
systemctl.
Reply
Ad
AD Aaron Kili
vivo V21 Be The Light at Night
April 25, 2019 at 10:17 am
vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 16/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
@Oli
Yes, your concern is true, but these are essentially Nginx service management
systemctl commands. Thanks for the feedback.
Reply
Got something to say? Join the discussion.
Have a question or suggestion? Please leave a comment to start the discussion. Please
keep in mind that all comments are moderated and your email address will NOT be
published.
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Ad
AD
vivo V21 Be The Light at Night
Notify me of followup comments via e-mail. You can also subscribe without
vivo Bangladesh
commenting.
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 17/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
Post Comment
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Over 3,500,000+ Readers
A Beginners Guide To Learn Linux for Free [with Examples]
Red Hat RHCSA/RHCE 8 Certification Study Guide [eBooks]
Linux Foundation LFCS and LFCE Certification Study Guide [eBooks]
Ad
AD
vivo V21 Be The Light at Night
vivo Bangladesh
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 18/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
AD
vivo V21 Be The
Light at Night
V21 the best camera
phone with 44MP OIS
Super Night Selfie
camera & 64MP OIS
Night Camera
vivo Bangladesh
Shop Now
Learn Linux Commands and Tools
2 Ways to Create an ISO from a Bootable USB in Linux
How to Limit File Download Speed Using Wget in Linux
30 Useful Linux Commands for System Administrators
How to Switch (su) to Another User Account without Password
Ad
AD
vivo V21 Be The Light at Night
How to Create Hard and Symbolic Links in Linux
vivo Bangladesh
5 Command Line Tools to Find Files Quickly in Linux
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 19/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
If You Appreciate What We Do Here On TecMint, You Should Consider:
Linux Server Monitoring Tools
Petiti – An Open Source Log Analysis Tool for Linux SysAdmins
Ad
AD
vivo V21 Be The Light at Night
How To Install and Connect an Agent to Pandora FMS Server
vivo Bangladesh
How to Use ‘fsck’ to Repair File System Errors in Linux
SHOP NOW
https://www.tecmint.com/useful-nginx-command-examples/ 20/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
How to Install Nagios 4 in Ubuntu and Debian
Install OpenNMS Network Monitoring Tool in CentOS/RHEL 7
How to Install vnStat and vnStati to Monitor Network Traffic in Linux
Learn Linux Tricks & Tips
How to Split Large ‘tar’ Archive into Multiple Files of Certain Size
How to Create Hard and Symbolic Links in Linux
How to Find and Remove Duplicate/Unwanted Files in Linux Using ‘FSlint’ Tool
How to Extract Tar Files to Specific or Different Directory in Linux
Gogo – Create Shortcuts to Long and Complicated Paths in Linux
5 Useful Commands to Manage File Types and System Time in Linux – Part 3
Best Linux Tools
16 Open Source Cloud Storage Software for Linux in 2020
The Best Microsoft Excel Alternatives for Linux
10 Best Markdown Editors for Linux
16 Best Open Source Video Players For Linux in 2020
10 Best GitHub Alternatives to Host Open Source Projects
30 Best File Managers for Linux Systems
Donate to TecMint Contact Us Advertise on TecMint Linux Services Copyright Policy
Privacy Policy Career Sponsored Post
Tecmint: Linux Howtos, Tutorials & Guides © 2021. All Rights Reserved.
The material in this site cannot be republished either online or offline, without our permission.
https://www.tecmint.com/useful-nginx-command-examples/ 21/22
7/20/2021 10 Most Used Nginx Commands Every Linux User Must Know
Hosting Sponsored by : Linode Cloud Hosting
https://www.tecmint.com/useful-nginx-command-examples/ 22/22