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.
Learn AWS fundamental concepts including Regions, Availability Zones, and Virtual Private Clouds (VPCs)
- 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.
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
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 (
You will see the Nginx welcome page.
Nginx Configuration Details
- Nginx location:
- Main Nginx configuration file:
- Additional Nginx configuration files for websites:
- Default web root for the Nginx installation:
- Nginx error log file:
- Nginx access log file:
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.