SystemMen - How to install latest Nginx in CentOS 7? This article will guide you step by step to do that.
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
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
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.If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.