The objective of this article is to provide the user with an information how to restart NGINX on Ubuntu 20.04 Focal Fossa

In this tutorial you will learn:
  • How to gracefully reload NGINX on Ubuntu
  • How to restart NGINX on Ubuntu
How to restart NGINX on Ubuntu 20.04 Focal Fossa
How to restart NGINX on Ubuntu 20.04 Focal Fossa

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed or upgraded Ubuntu 20.04 Focal Fossa
Software NGINX
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to restart NGINX on Ubuntu 20.04 step by step instructions

There are two main ways on how to restart the NGINX webserver on Ubuntu Linux:
  • reload - reloads the configuration file and keeps any existing client connection intact
  • restart - fully restarts the NGINX server and closes any existing client connections

  • SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Even though both above methods check the configuration during the restart/reload procedure it is always advisable to check the NGINX web-server configuration using 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
Since the Ubuntu 20.04 Focal Fossa Server/Desktop is based on systemd the following two methods are recommended to restart the the NGINX web server.
DID YOU KNOW?
You can check whether the NGINX web-server has been fully restarted by checking for Main PID number using the sudo systemctl status NGINX command before and after the restart.
  1. Using the systemcltcommand gracefully reloads the NGINX webserver:
    $ sudo systemctl reload nginx
    
  2. This method fully restarts the NGINX web-server:
    $ sudo systemctl restart nginx
    
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.