NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. In this article, we are going to discuss popular Nginx commands that is frequently use to manage Nginx server.
Prerequisites
- System with Nginx installed and configured
- Access to a terminal window or command line
- A user account with sudo or root privileges
Below are listed the main arguments to manage the Nginx server service:
start
: To start the Nginx server service.stop
: It is used to stop/terminate the Nginx server service.restart
: It is used to stop and then start the Nginx server service again.reload
: To Trestarts the Nginx service. On the reload, main Nginx server process shuts down the child processes, loads the new configuration, and starts new child processes.status
: It is shows the Nginx server service status.
Check Nginx Server Version
Run the command below to check the version of installed Nginx on your system:
nginx -v
Output
nginx version: nginx/1.14.0 (Ubuntu)
The command above will show only version information, but if you want to know version and configure option details of install Nginx then run the command below:
nginx -V
Testing Nginx Configuration Syntax
When you made changes in the Nginx server’s configuration file then it is a good practice to test the configuration syntax before restarting or reloading the Nginx service.
To test the Nginx configuration for syntax or system errors:
sudo nginx -t
Output
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Start Nginx Service :
Simply run the command below to start Nginx:
sudo systemctl start nginx
Run the command below to start Nginx if you have a Linux distribution without systemd:
sudo service start nginx
Enable Nginx Service
If you don’t want to start Nginx service manually, then you can set it auto-start on system boot by running command below:
sudo systemctl enable nginx
Run the command below who have a Linux distribution without systemd:
sudo service enable nginx
Stop Nginx Service
Run the command below to stop Nginx services:
sudo systemctl stop nginx
OR
sudo service nginx stop
Restart Nginx Service
Use the commands below to restart Nginx service:
sudo systemctl restart nginx
OR
sudo service restart nginx
Reload Nginx Service
To reload Nginx Services, run the commands below:
sudo systemctl reload nginx
OR
sudo service reload nginx
View Nginx Service Status
If you want to check the status of Nginx service then run the command below:
sudo systemctl status nginx
The above command will show the run time status information about the Nginx service.
That’s all.
If you face any error and issue in above steps , please use comment box below to report.
If our article helps you, please consider buying us a coffee
Thank you for your support.