We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

How to Install Nginx on CentOS 8 – Google Cloud/AWS

How to Install Nginx on CentOS 8 – Google Cloud or AWS. Nginx is high performance light-weight HTTP and reverse proxy web server capable of handling large websites. This guide explains how to install Nginx on CentOS 8.

This tutorial is tested on Google Compute Engine VM Instance running CentOS 8. This setup will also work on other cloud services like AWS, DigitalOcean, etc or any VPS or Dedicated servers.

Prerequisites

  1. A running system or server or a virtual machine with CentOS 8

If you are using Google Cloud then you can learn how to setup CentOS 8 on a Google Compute Engine.

Update Packages

Start by updating the packages to the latest available version using the following commands.

sudo yum update
sudo yum upgrade

Once you have all packages are up to date you can proceed to install Nginx.

Install Nginx on CentOS 8

Nginx is available in the default CentOS repositories. So it is easy to install Nginx with just a single command.

sudo yum install nginx

Once the installation is completed, you need to start and enable Nginx to start on server boot.

sudo systemctl enable nginx
sudo systemctl start nginx

Verify the Installation

To verify the status of the Nginx service you can use the status command.

sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
    Active: active (running) since Wed 2019-11-27 08:34:48 UTC; 1min 1s ago
   Process: 823 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
   Process: 821 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
   Process: 820 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
  Main PID: 825 (nginx)

This indicates Nginx is up and running on your CentOS server.

Setup Firewall for Nginx

Upon installation Nginx creates predefined rules to accept connections on port 80 for HTTP and 443 for HTTPS

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

Now you can check your browser by pointing it to your public IP address (http://IP_Adddress).

You will see the Nginx welcome page.

Nginx Welcome page

Nginx Configuration Details

  • Nginx location: /etc/nginx
  • Main Nginx configuration file: /etc/nginx/nginx.conf
  • Additional Nginx configuration files for websites: /etc/nginx/conf.d
  • Default web root for the Nginx installation: /var/www/html
  • Nginx error log file: /var/log/nginx/error.log
  • Nginx access log file: /var/log/nginx/access/log

Prepare yourself for a role working as an Information Technology Professional with Linux operating system

Conclusion

Now you have learned how to install Nginx on your CenOS 8 server on any hosting plaforms.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Cart

Your Cart is Empty

Back To Shop