Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

Install Nginx (Latest Version) on CentOS 7

Published on April 1, 2019 44 sec read

Nginx [engine x] is an HTTP and reverse proxy server. It is free and open source high-performance web server. Today we will install the latest version of Nginx on CentOS server. It also works on RHEL 7.

Step 1 : Login to Server

At first, we need to login to our server via SSH. Open your terminal and run this command:

ssh [email protected] -p PORT

Step 2 : Configure Nginx Repo

Run this command:

sudo nano /etc/yum.repos.d/nginx.repo

Now copy and paste this code to nginx.repo file (SHIFT+INS):

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0

Step 3 : Install Nginx

Run this command to install Nginx:

sudo yum install nginx

Start Nginx server:

sudo systemctl start nginx

Enable Nginx to start at boot:

sudo systemctl enable nginx

Step 4 : Useful Commands

Here’s some useful Nginx commands:

sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl status nginx

Step 5 : Advanced (Firewall)

If you are running Firewall on your server, then run the following commands to allow HTTP and HTTPS traffic:

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

Now open a web browser and type the IP address of your server to see the output:

You're welcome to suggest any article to write!

Md Obydullah Follow I'm Md Obydullah. I build open-source projects and write about Laravel, Linux server, modern JavaScript and web development.

One Reply to “Install Nginx (Latest Version) on CentOS 7”

Leave a Reply

Your email address will not be published. Required fields are marked *