How to Install Nginx on Your Ubuntu 22.04 Host Server

NGINX (pronounced “engine-x”) is a popular open-source web server, reverse proxy server, load balancer, and HTTP cache. It is often used as a front-end proxy server to distribute incoming web traffic across multiple backend servers, improving reliability and performance. Here are the steps to install NGINX on your Ubuntu 22.04 host server:

1. Update the Package List:

Start by updating the package list to ensure that you are working with the latest available packages:

```bash

sudo apt update

```

 

2. Install NGINX:

You can install NGINX using the `apt` package manager with the following command:

```bash

sudo apt install NGINX

```

During the installation process, you will be prompted to confirm that you want to install NGINX. Type “Y” and press Enter to proceed.

3. Start NGINX:

Once the installation is complete, you can start the NGINX service using the following command:

```bash

sudo systemctl start NGINX

```

This will start the NGINX web server.

4. Enable NGINX to Start on Boot:

To ensure that NGINX starts automatically when your server reboots, enable it as a systemctl service:

```bash

sudo systemctl enable NGINX

```

 

5. Check the NGINX Status:

You can verify that NGINX is running and active by checking its status:

```bash

sudo systemctl status NGINX

```

If NGINX is running, you should see output indicating that the service is active and enabled.

6. Adjust the Firewall (if needed):

If you have a firewall enabled on your server, you’ll need to allow HTTP traffic (port 80) to reach your NGINX web server. You can do this with the following command:

```bash

sudo ufw allow 'NGINX HTTP'

```

This will allow incoming HTTP traffic to your server.

7. Access the Default NGINX Page:

Open a web browser and enter your server’s IP address or domain name in the address bar. If you don’t know your server’s IP address, you can find it by running:

```bash

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

```

You should see the default NGINX welcome page, indicating that NGINX is successfully installed and running.

NGINX is now installed and configured on your Ubuntu 22.04 host server. You can start deploying your web applications or websites on it.

Have additional questions? Search below: