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:
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:
After that, start the Nginx service:
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:
To verify if the HTTP firewall service was correctly added to the system, execute this command:
Now, you have to reload the firewall service:
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:
The modern way of executing the systemctl command for checking the Nginx status is as follows:
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:
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.