How to install latest Nginx in CentOS 7

by Daniel Pham
Published: Updated:

How to install latest Nginx in CentOS 7? This article will guide you step by step to do that.

Test environment

I will use a Linux machine with the following configuration to test:

  • OS: CentOS 7.6.1810 (Core).
  • HDD: more than 5GB free.
  • RAM: more than 1GB free.
  • User: root.

Steps to install the latest Nginx in CentOS 7

Install Nginx

how to install latest nginx in centos 7
How to install latest Nginx in CentOS 7.

First, run the following command to create a new file for the Nginx repository.

[root@centos7 ~]# nano /etc/yum.repos.d/nginx.repo

If you encounter an error like below.

bash: nano: command not found

Run this command to resolve it.

[root@centos7 ~]# yum install nano wget -y

Recommended Reading: What is Nginx?

After running the nano command to create the nginx.repo file, copy the content below to that file and save it.

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

Next, update the software packages in the server.

[root@centos7 ~]# yum update -y

And finally run the latest Nginx installation command for CentOS 7 machine.

[root@centos7 ~]# yum install nginx -y

At the time of this article, the latest stable version of Nginx is version 1.14.2.

Enable Nginx and use

To enable Nginx service in CentOS 7, type the following command.

Recommended Reading: How to install latest Nginx on Debian 8

[root@centos7 ~]# systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service, pointing to /usr/lib/systemd/system/nginx.service.

Start Nginx service for the first time.

[root@centos7 ~]# systemctl start nginx

And you can check if service port 80 is working or not with the following command.

[root@centos7 ~]# netstat -lnptu | grep 80

Conclusion

The article covered step by step so that you can successfully install the this webserver in CentOS 7. Now, you can start declaring virtual hosts on the server and add your websites there.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.