Site icon Hostbillo Blog – Web Hosting, Devops, Tech, and more

How to Start, Stop, and Restart Nginx in Linux? (2 Methods)

How to Start, Stop, and Restart Nginx in Linux

Introduction

A quick, dependable, open-source, and cost-free web server is Nginx. Being a load balancer, proxy server, and additionally, mail proxy, start Nginx can get configured for use.

Several typical operations get carried out when working with any server. This covers the server’s launch, shutdown, and restart Nginx.

Managing these tasks on Linux for the Nginx server will be covered in this article. The Nginx web server’s starting, stopping, and restarting are some of the most frequent activities you’ll experience. The Nginx service can be started, stopped, and restarted using the instructions in this guide.

System Requirements

The system needs the following to understand its fundamentals:

Start, Stop and Restart Nginx using systemctl

The Best Way to Check Your Nginx Server’s Status

Your server is running Nginx as a service. If nothing appears on the screen, it should still function actively in the background. The following command can be entered in a terminal window to show the current state of the start Nginx service:

An extensive amount of data about the Nginx service will be displayed once the system enters a status mode.

Reopen the bash prompt by pressing Q.

Current Linux distributions, including Ubuntu and CentOS as well as Debian, all come standard with SystemD as their service manager. Utilizing the systemctl command, your SystemD manager operates.

Among the fundamental Linux commands is systemctl. In other words, it can be applied to any Linux service.

Also Read: 50+ Linux Commands with Screenshots (Download PDF)

Turn off and on Nginx

Starting and stopping the Nginx service is possible via systemctl.

Use the following command to stop Nginx:

Turn on Nginx by using the systemctl command using the start Nginx option:

Steps for Restarting Nginx

Restart Nginx considerately

It’s advisable to gently reload the service when refreshing Nginx following configuration changes. The updated configuration ends existing processes and begins new ones.

To relaunch the Nginx service on Linux, execute the systemctl command. Enter the command below:

Reloading Nginx is not possible when the Nginx services are not running.

Forcing Nginx to Restart

You can force Nginx to relaunch entirely when making significant configuration updates. The entire service and its dependent processes get forced to end, and the entire application gets restarted.

Execute the command as follows:

Nginx: Restart compared to Reload

The reload command allows the Nginx server to continue operating while reloading modified configuration files. Any configuration file reload gets stopped if Nginx detects a syntax issue and the server continues to operate using the previous configuration files. Compared to restarting Nginx, reloading is more secure.

Restarting the server will turn off all associated services as well as the server itself. If you’re changing ports and interfaces, for example, you should only restart Nginx after performing important configuration changes. Using this command will end all worker processes forcibly.

Create a boot configuration for Nginx

When using the systemctl command, utilize the enable option to turn on Nginx.

When using the systemctl command, employ the disable option to turn off Nginx.

Start, Stop and Restart Nginx using the Command Line

The Nginx command provides access to the collection of integrated management tools that Nginx provides for the service.

Nginx Startup

Input the following information to launch Nginx and related services:

The terminal window output is going to display the following when the operation is successful:

The output

Restarting Nginx

To forcefully terminate and relaunch Nginx and associated processes:

On the other hand, utilize this nginx -s command:

Stop Nginx

Use the next commands to shut down or stop Nginx service:

Another option is to utilize:

Reloading Nginx

Nginx and associated processes can be properly stopped nginx and restarted by using the following command:

If you’d rather give Nginx directions straight away, you can do this by using the nginx -s command:

Quit Nginx

By combining the quit command alongside the nginx -s command, you can force the Nginx service to end:

Start, Stop and Reload Nginx using SysVinit

The Nginx daemon gets started, stopped, and restarted utilizing init.d scripts in previous (EOLed) editions of Ubuntu, CentOS, as well as Debian.

Restarting the Nginx service

Starting the Nginx services

Terminate the Nginx service

Also Read: How to Use apt-get reinstall on Debian and Ubuntu?

Summing Up

Several techniques on how to start, stop, and restart Nginx on your server have been described in this post. If you’re administering an Nginx web server, utilize the commands mentioned above for the tasks that come up the most often.

Exit mobile version