How to Install Nginx: A Beginner's Guide

Nginx notes:

  1. How to Install Nginx: A Beginner's Guide
  2. (HA) Load balancing for .Net Core use Nginx
  3. (HA) Load balancing for Angular App

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

Install the NGINX package

The following command installs the NGINX package and all of its dependencies:

sudo dnf install -y nginx

Enable and start the NGINX service

To enable and start the NGINX service for immediate access and make the service start automatically after a reboot, run the following command:

sudo systemctl enable --now nginx.service

The service starts a web server that listens on TCP port 80 by default. To check the status of the service, run this command:

sudo systemctl status nginx

Configure firewall rules (Optional)

If you are using a custom firewall profile or an Oracle Cloud Infrastructure instance, open the firewall port for the NGINX web service (80).

These commands enable the firewall port for the NGINX web service and reload the default firewall service:

sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload

Note that in the demonstration environment, the instance has a public facing IP address and no network security is applied. Depending on your production environment, you may need to configure additional security list rules or update your network security group configuration.

Some Error and Solutions

1. Permission denied
Permission denied

Solution: 

setsebool -P httpd_enable_homedirs 1
setenforce 0
systemctl restart nginx
systemctl daemon-reload
RyanX April 22, 2024
Share this post
Tags
Archive