# How to install Nginx on CentOS 8?

{% embed url="<https://youtu.be/12JkHt9LVyY>" %}

### **Overview** <a href="#howtoinstallnginxoncentos8-introduction" id="howtoinstallnginxoncentos8-introduction"></a>

One of the most widely used web servers in the world, Nginx is in charge of hosting some of the biggest and most well-known websites on the internet. It may be used as a reverse proxy or web server and often uses fewer resources than Apache.

You will discover how to set up Nginx on CentOS 8 in this tutorial.

### **Prerequisites** <a href="#howtoinstallnginxoncentos8-prerequisites" id="howtoinstallnginxoncentos8-prerequisites"></a>

There are certain prerequisites that need to be met before you begin.&#x20;

* A machine running CentOS 8
* A root user having Sudo privileges
* Internet connection

### **Get Started** <a href="#howtoinstallnginxoncentos8-step1.installingnginxoncentos8" id="howtoinstallnginxoncentos8-step1.installingnginxoncentos8"></a>

#### **Step 1. Installing Nginx on CentOS 8** <a href="#howtoinstallnginxoncentos8-step1.installingnginxoncentos8" id="howtoinstallnginxoncentos8-step1.installingnginxoncentos8"></a>

* Always update the local repository before doing any installations to make sure you are obtaining the most recent software. Use the following command to do it:

```
sudo yum update
```

* Before installing the Nginx package on your system, you can inspect it. Request a copy of the RPM metadata that comes with each RPM package:

```
sudo yum info nginx
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1511_1.-Nginx.png)

* Next, execute the following command to install Nginx on CentOS 8:

```
sudo yum install nginx
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1512_2.-Nginx.png)

As seen in the screenshot above, the result displays a list of the installed Nginx packages.

#### **Step 2. Launching Nginx on Centos 8** <a href="#howtoinstallnginxoncentos8-step2.launchingnginxoncentos8" id="howtoinstallnginxoncentos8-step2.launchingnginxoncentos8"></a>

Despite the fact that Nginx is installed, the service won't start on its own.

* To launch the service, type:

```
sudo systemctl start nginx
```

* Use the following command to make it possible for the service to launch at boot time.

```
sudo systemctl enable nginx
```

* Execute the below command to view the service status. Nginx should be active (running).

```
sudo systemctl status nginx
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1513_3.-Nginx.png)

#### **Stop, Reload or Restart Nginx** <a href="#howtoinstallnginxoncentos8-stop-reloadorrestartnginx" id="howtoinstallnginxoncentos8-stop-reloadorrestartnginx"></a>

* **Stop Nginx:** Use this command to terminate Nginx:

```
sudo systemctl stop nginx
```

* **Restart Nginx:** To halt and restart the service, enter the following command:

```
sudo systemctl restart nginx
```

* **Reload Nginx:** Use the below command to reload the service without stopping to change the configuration files:

```
sudo systemctl reload nginx
```

#### **Step 3. Adjusting Firewall** <a href="#howtoinstallnginxoncentos8-step3.adjustingfirewall" id="howtoinstallnginxoncentos8-step3.adjustingfirewall"></a>

* Use the firewall-cmd commands listed below to open and enable ports 80 and 443 on the system firewall so that Nginx web traffic is permitted.

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

```
sudo firewall-cmd --reload
```

```
sudo firewall-cmd --list-services --zone=public
```

#### **Step 4. Testing your Web Server** <a href="#howtoinstallnginxoncentos8-step4.testingyourwebserver" id="howtoinstallnginxoncentos8-step4.testingyourwebserver"></a>

Now that your server's public IP address or domain name is accessible from a web browser, you may check to see if your Nginx web server is operational.&#x20;

* In the terminal, use the following command to view your server's IP address:

```
ip addr
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1514_4.-Nginx.png)

Open a web browser after that, and then put the IP address (or domain name) into the address bar. The Nginx Welcome Page should then load, indicating that the server has been successfully installed and configured.

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1515_5.-Nginx.png)

### **Conclusion** <a href="#howtoinstallnginxoncentos8-conclusion" id="howtoinstallnginxoncentos8-conclusion"></a>

This tutorial has shown you how to install and configure Nginx. From here, you have a wide range of options for the technologies and content types that you might utilize in the websites that are hosted on your web server.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.acecloud.ai/knowledge-base/tutorials/how-to-install-nginx-on-centos-8.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
