Sunday, September 25, 2022

How to install NGINX on centos 7

In this article, we want to teach you what Nginx is and show you How to install Nginx on centos 7.

Before we go to install Nginx let’s see what Nginx is and how it works.

What is Nginx?

Nginx is open-source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, Nginx can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers. And it is more flexible than the Apache HTTP server.

How to install NGINX on centos 7

To install Nginx on Centos 7, It’s better to log in as a non-root user with root privileges. you can check this on the Initial server setup with Centos 7 article.

Add Nginx repository on Centos 7

For installing Nginx you should add the centos 7 EPEL repositories first with the following command:

sudo yum install epel-release

Install Nginx

Install Nginx with the following command:

sudo yum install nginx

Answer yes to install. Then start Nginx on Centos 7 with the following command:

sudo systemctl start nginx

Note: if you are running a firewall you should allow HTTP and HTTPS traffic with the following commands:

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd –reload

Note: If you haven’t firewalld first install it then run the commands above.

sudo yum install firewalld

Start firewalld with the following command:

sudo systemctl start firewalld

Don’t forget to run the commands above after firewalld installation.

You need your IP address at this point. You can find your public IP address by running the command below:

ip addr

In your output, the eth0 interface is what we want. Run the following command to get your IP address:

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Now you can test by visiting your server’s public IP address in your web browser.

http://server_domain_name_or_IP/

Here you will see the default CentOS 7 Nginx web page in your web browser.
If you see the page your web browser is correctly installed and working.

conclusion

At this point, you learn what Nginx is and you know about Epel repositories and adding them on centos 7 and you can easily install Nginx on Centos 7.

Hope you enjoy this article about how to install NGINX on centos 7.
Stay with us for more articles.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular