Nginx

How do I check Nginx status

Nginx is an open-source, freely available web server that can be utilized for video streaming, caching, load balancing, reverse proxy, and other applications. Nginx developers aimed it to be designed as a web server that provides maximum performance and stability. In addition, to act as an HTTP server, Nginx can also operate as a reverse proxy, an email proxy server (SMTP, IMAP, POP3), and a load balancer for UDP, TCP, and HTTP servers.

In October 2004, “Igor Sysoev” designed Nginx, which was first released to the public. Igor originally envisioned the software as a solution to the C10k problem. It often surpasses other popular web servers’ benchmark testing, especially in handling static content or heavy concurrent requests. Several well-known companies such as Google, Intel, Netflix, Github, Apple, Twitter, LinkedIn, Microsoft, IBM, Adobe, are using Nginx.

How Does Nginx Work in CentOS

Nginx provides high concurrency and low memory usage. It utilizes an asynchronous, event-driven method that handles requests in a single thread rather than generating separate processes for each web request. One master process can supervise several worker processes in Nginx. The worker processes are maintained by the master, while the worker processes conduct the actual processing. As Nginx is asynchronous, each request is processed concurrently by the worker processes without causing other requests to be blocked.

What are the features of Nginx in CentOS

Nginx has several commendable features, including:

  • IPv6 support
  • Load balancing
  • TLS/SSL with SNI
  • Web sockets
  • Reverse proxy with caching
  • FastCGI support with caching
  • Handling of index files, static files, and auto-indexing

Verifying the status of Nginx on your system is another essential thing while working with it. This post will demonstrate how to check Nginx in my CentOS system. Before moving towards it, install Nginx if you do not have it already on your CentOS system.

How to install Nginx in CentOS

Firstly, open up your CentOS terminal by pressing “CTRL+ALT+T” and then write out the below-given command:

$ sudo yum install nginx

The error-free output declares that Nginx is successfully installed on your system.

How to enable Nginx in CentOS

Now, utilize the below-given command for enabling Nginx on CentOS system:

$ sudo systemctl enable nginx

After that, start the Nginx service:

$ sudo systemctl start nginx

How to set firewall rules for Nginx in CentOS

The next thing we are going to do is set the firewall settings to permit the external connections for the Nginx, running on port 80 by default. firewall-cmd is the command that is utilized for managing permanent and runtime firewalld configuration.

For permanently enabling the HTTP connections on port 80, write out the below-given command in your CentOS terminal:

$ sudo firewall-cmd --permanent --add-service=http

To verify if the HTTP firewall service was correctly added to the system, execute this command:

$ sudo firewall-cmd --permanent --list-all

Now, you have to reload the firewall service:

$ sudo firewall-cmd --reload

All done! Now you will learn how to check the Nginx status.

How to check Nginx status in CentOS

To verify if the Nginx is currently running on your system or not, you have to check its status on your system. In the section, we have compiled two different methods for you to check the Nginx status on CentOS:

How to check Nginx status using systemctl in CentOS

A systemctl command is a tool utilized for controlling and investigating the systemd service manager and systemd Linux initialization system. It is a set of system administration libraries, daemons, and utilities that replace the SystemV init daemon.

You can execute systemctl command for checking the Nginx status on a CentOS system:

$ sudo systemctl status nginx

The modern way of executing the systemctl command for checking the Nginx status is as follows:

$ systemctl is-active nginx

Here, the output declares that Nginx is “active” on our system:

How to check Nginx status using lsof in CentOS

The lsof is an acronym for “list open files”. The lsof command displays the active user processes on a file system. It can be useful in figuring out why a file system is still in use and can not be unmounted.

Utilize the lsof command with the “-i” option for viewing all the executing processes on a certain port. Execution of the below-given command will show you all of the processes that are currently running on port 80:

$ sudo lsof -i TCP:80

Conclusion

Nginx is a high-performance HTTP server, reverse proxy, and POP3/IMAP proxy server that is freely available and open-source. It does not utilize threads for processing requests; instead, it employs an asynchronous, event-driven architecture that is far more scalable. In this post, we have demonstrated how to install and configure Nginx. I have also shared how do I check Nginx status on my CentOS system.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.