Nginx is an open-source, light weight, high-performance HTTP / HTTPS and reverse proxy server responsible for handling the load of some of the largest websites on the Internet. It can be used as a standalone web server, load balancer, content cache, and reverse proxy for HTTP and non-HTTP servers.
Compared to Apache, Nginx can handle a much large number of concurrent connections and has a smaller memory footprint per connection. Hence, it is highly preferred for the systems with more traffic requests.
This tutorial explains how to install and manage Nginx on CentOS 8.
Table of Contents
Before continuing, make sure you are logged in as a user with sudo privileges, and you don’t have Apache or any other process running on port 80 or 44. Make sure these ports are also not blocked by firewalls.
Starting with CentOS 8, the Nginx package is available in the default CentOS repositories. Hence there is no need to import any 3rd party repository. Simple execute the following command on your CentOS terminal.
sudo yum install nginx On completion of successful installation, you would like to start Nginx server by executing command below.
sudo systemctl start nginx On rebooting server, Nginx will not start automatically. To automatically start Nginx server on reboot or startup, execute the command below.
sudo systemctl enable nginx To verify the status of Nginx, you can use the following command.
sudo systemctl status nginx Output will look like as:
● nginx.service - The nginx HTTP and reverse proxy serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)Active: active (running) since Saturday 2019-10-05 17:32:45 UTC; 5min ago... FirewallD is the default firewall solution on Centos 8. However, you may be using UFW.
During the installation, Nginx creates firewalld service files with predefined rules for allowing access to HTTP (80) and HTTPS (443) ports.
Use the following commands to open the necessary ports permanently:
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload Now, you can test your Nginx installation, by opening http://YOUR_IP in your web browser. You should see the default Nginx welcome page, which should look like the image below:
With Systemd service:
sudo systemctl start nginx Without Systemd service:
sudo service start nginx To enable auto start of Nginx on rebooting:
sudo systemctl enable nginx With Systemd service:
sudo systemctl stop nginx Without Systemd service:
sudo service stop nginx With Systemd service:
sudo systemctl restart nginx Without Systemd service:
sudo service restart nginx With Systemd service:
sudo systemctl reload nginx Without Systemd service:
sudo service reload nginx sudo nginx -t sudo systemctl status nginx sudo nginx -v /etc/nginx/ directory./etc/nginx/nginx.conf..conf and be stored in /etc/nginx/conf.d directory. You can have as many server blocks as you want.mydomain.com then the configuration file should be named mydomain.com.confaccess.log and error.log) are located in the /var/log/nginx/ directory. It is recommended to have a different access and error log files for each server block./home/<user_name>/<site_name>/var/www/<site_name>/var/www/html/<site_name>/opt/<site_name>/usr/share/nginx/htmlCongratulations, you have successfully installed Nginx on your CentOS 8 server. You’re now ready to start deploying your applications and use Nginx as a web or proxy server.
NGINX Server Nginx, a popular open-source web server, excels at handling high traffic websites efficiently.… Read More
In the realm of web hosting, choosing the right web server is paramount. It acts… Read More
Are indispensable for ensuring smooth, precise linear motion in many industrial applications. Whether in robotics,… Read More
Cyber attacks are becoming more frequent, complex, and damaging. They can disrupt critical operations and… Read More
With the rise of new threats and the increasing complexity of IT environments, organizations need… Read More
1. Introduction In software design, managing complex systems can be challenging. The Facade Design Pattern… Read More