Redhat 7 install nginx server

Simple tutorial about how to install nginx server on Redhat linux

Check if you have nginx service enabled already

systemctl list-unit-files | grep nginx

If nginx service is disabled, enable it by typing

systemctl enable nginx.service

Start nginx service, you’ll need to open firewall ports to allow nginx server content to be accessible from public.

systemctl start nginx.service

# Open firewall ports for nginx
firewall-cmd --permanent --add-port={80/tcp,443/tcp}
firewall-cmd --reload

If you don’t have nginx installed, follow below steps to install it.

# Add nginx repo to your server. source, create a repo file under below location
touch /etc/yum.repos.d/nginx.repo

# Edit above repo file, update content as below (RHEL 7 only)
[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/rhel/7/x86_64/
gpgcheck=0
enabled=1

Save this file and type “yum update” to install nginx

yum update

# Install nginx, once nginx get installed, repeat step to enable and start nginx service.
yum install nginx

Open firewall ports and verify

firewall-cmd --permanent --add-port={80/tcp,443/tcp}
firewall-cmd --reload

# Verify , you should have 80 and 443 ports opened
firewall-cmd --list-ports

Enable nginx as system service

# This will run nginx automatically when system starts.
systemctl enable nginx

Verify nginx installation

# Check installed nginx
yum list installed nginx
# Sample output
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Installed Packages
nginx.x86_64                                                                                           1:1.20.1-9.el7                                                                                           @epel
#Start nginx server
sudo systemctl start nginx
# Check nginx is enabled
systemctl is-enabled nginx

Now you should have nignx up and running.

Reference:

https://www.nginx.com/resources/wiki/start/topics/tutorials/install/

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_different_types_of_servers/setting-up-and-configuring-nginx_deploying-different-types-of-servers

Leave a Comment

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


The reCAPTCHA verification period has expired. Please reload the page.

Scroll to Top