How to Install Nginx on RHEL 7/ Redhat

How to Install Nginx on RHEL 7/ Redhat

by default, redhat yum repository will provide you nginx, so you can install nginx on redhat or rhel 7 with yum install command.

sudo yum install nginx -y

Verify Nginx Status

after installing nginx on your rhel 7 or Redhat server, verify is nginx running or not by using status command.

systemctl status nginx

[root@ip-172-31-21-11 ~]# systemctl status nginx
? nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Jun 23 08:16:59 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: Started The nginx HTTP and reverse proxy server.
Jun 23 09:43:43 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Jun 23 09:43:43 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Jun 23 09:43:43 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jun 23 09:43:43 ip-172-31-21-11.us-east-2.compute.internal nginx[15511]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jun 23 09:43:43 ip-172-31-21-11.us-east-2.compute.internal nginx[15511]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jun 23 09:43:43 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Jun 23 09:43:43 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: Started The nginx HTTP and reverse proxy server.
Jun 23 10:20:42 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: Stopping The nginx HTTP and reverse proxy server...
Jun 23 10:20:42 ip-172-31-21-11.us-east-2.compute.internal systemd[1]: Stopped The nginx HTTP and reverse proxy server.

Here in my case nginx is not running so lets start the nginx service.

Start Nginx Service

start the nginx service with start command.

systemctl start nginx

Add Nginx Ports To Firewall

by default nginx is running port 80 for http and port 443 for https access.

if you are using firewalld in your machine then add nginx ports to this firewalld using below commands.

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

Note: if you are using aws ec2 instances open 80,443 ports in inbound rules in security groups

Access Nginx in Browser:

you can access nginx webpage by entering Public IP address of your machine in the browser.

enter http://ip OR http://public_ip.

  • install nginx on redhat 7
  • nginx installation on rhel 7
  • nginx installation
  • how to install nginx on rhel 7
  • how to install nginx on redhat 7

Leave a Reply

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