A strong server program called Nginx is used to direct network traffic. Although it may be set up as a standard web server, Nginx. service is Not Active, Cannot Reload it is frequently used as a reverse proxy server.
Starting, halting, and restarting the Nginx web server is one of the most frequent procedures you will experience.
Here at Arzhost, we Learn how to start, stop, and restart the Nginx service in this lesson:
- A machine with Nginx installed and set up
- Access to a command line or terminal window
- A user account with root or sudo access
- If operating remotely, an active SSH connection to a distant system
Using systemctl, start, stop, and restart Nginx
If your Nginx. Service is Not Active, Cannot Reload lets us check the server’s status visibility on the screen.
1: How to Check Your Nginx Server’s Status
On your server, Nginx is active as a service. This means that even if nothing is visible on the screen, it should run actively in the background.
Enter the following command in a terminal window to view the Nginx service’s status:
systemctl status nginx with sudo
The system will enter a status mode and present a wealth of data regarding the Nginx service:
- The third line will display a green active (running) status if the service is active.
- Nginx will appear inactive in plain white if it is not running.
- You will notice a red status failed along with additional information if Nginx was unable to load due to an error.
To bring up the bash prompt once more, press q.
On contemporary Linux distributions (Ubuntu 20.04/18.04. /16.04, CentOS 7/7, and Debian 9/10), SystemD is the default service manager. The systemctl command controls how the SystemD manager works.
A fundamental Linux command is called systemctl. As a result, it can be applied to any Linux service.
2: Turn off and on Nginx
The Nginx service can be started and stopped using systemctl.
Run the following command to terminate Nginx:
systemctl sudo stop nginx
Use the systemctl command with the start option to start Nginx:
systemctl start nginx sudo
How to Start Nginx Again?
1: Restart Nginx politely
After modifying the settings, it’s best to reload the service while refreshing Nginx gently. With the new setup, new processes are started and old ones are terminated.
Reload the Nginx service on a Linux system by using the systemctl command. Run the command line:
systemctl reload nginx with sudo
2: Force Nginx to Restart
Nginx. service is Not Active, Cannot Reload. You can force Nginx to restart completely if you make significant configuration changes. This continues the entire package while also forcibly terminating the service and its subprocesses.
Input the command as follows:
systemctl sudo restart nginx
Nginx Restart vs. Nginx Reload
The reload command allows the Nginx server to continue operating while it loads new configuration files. The reload is stopped and the server continues to operate using the old configuration files if Nginx detects a syntax mistake in any of the configuration files.
It is safer to reload than to restart Nginx. The restart command will turn off the server and all associated services before turning them back on.
Only restart Nginx when you make substantial configuration changes, such as switching ports or interfaces. With this command, all worker processes will be abruptly terminated.
Setup Nginx to Run Upon Boot
To activate Nginx, use the systemctl command’s enable option:
systemctl sudo enable nginx
To disable Nginx, use the systemctl command with the disable option:
systemctl disable nginx sudo
Conclusion
Several techniques for starting, stopping, and restarting Nginx. Service is Not Active, Cannot Reload on your server have been covered in this article.
When operating an Nginx web server, use these commands for the tasks that are performed most frequently.