Nginx is a free and open source web server. It can also be used as a reverse proxy, HTTP cache, and load balancer. In this article, we will learn how to restart Nginx in Linux.
Before restarting Nginx, you can check its status with the following command:
$ sudo systemctl status nginx
Alternatively, you can check the configuration file to see if there are any errors prior to the restart process. You can do this by adding the -t
parameter to the command:
$ sudo nginx -t
Expected output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Restarting NGINX
reload
option should suffice to load the new settings. For troubleshooting and hard restarts, the restart
option will prove more useful.Now that we know that the configuration files have no issues, we can proceed to restart with the next commands.
This command will fully restart Nginx, closing out all current connections.
$ sudo systemctl restart nginx
This command will reload Nginx, causing it to reload new settings from the configuration files, without actually shutting it down:
$ sudo systemctl reload nginx