How To Install Nginx on CentOS 7 / RHEL 7 With Example

About

Nginx is a free, open source web server. It’s fast and lightweight when compared to the Apache web server and accurately provide predictable performance under very high loads.

Some Features:

  • Fully IPv6 compatible
  • Bandwidth Throttling
  • Handles static files, index files and auto-indexting
  • Support fault tolerance
  • URL Redirects and rewriting
  • Geolocation of IPs
  • Very low memory footprint
  • Open SSL Support

Install NGINX

Make sure you add the repository that contains the version and the application that you want to install. In our case we need an epel repository for us to begin and complete the installation

1.) To add the EPEL repository, open terminal and use the following command:

yum -y install epel-release

2.) Now the EPEL repository is installed on the server, we can now use yum command to install NGINX:

yum -y install nginx

3.) Start NGINX service

systemctl start nginx

4.) Now use the following command to enable Nginx service to start on boot

systemctl enable nginx

5.) Now you should be able to see test page by going to localhost or using your IP address for your server.

http://your_server_IP/
http://localhost/

6.) Configure Firewall
Run the following commands to allow HTTP and HTTPS traffic through firewall:

firewall-cmd --permanent --zone=public --add-service=http

firewall-cmd --permanent --zone=public --add-service=https

firewall-cmd --reload

7.) Configuration files for nginx are located in following directory

 /etc/nginx/

You now have a NGINX http web server running on CentOS 7 / RHEL 7. Have any questions ? Leave a comment below.

Enjoy!

Add Comment