logo
. . .

How to install Ngnix on Ubuntu

1. Update Package Lists: Before installing any new software, it’s a good practice to update the package lists on your system.

sudo apt update

2. Install Nginx on Ubuntu: Use the following command to install Nginx.

sudo apt install nginx

3. Start Nginx: After the installation is complete, start the Nginx service.

sudo systemctl start nginx

4. Enable Nginx to Start on Boot: Ensure that Nginx starts automatically when the system boots.

sudo systemctl enable nginx

5. Check Nginx Status: Confirm that Nginx is running without errors.

sudo systemctl status nginx

This command will display the status and other information about the Nginx service.

6.Configure Firewall: If you have a firewall enabled, such as UFW,

you may need to allow traffic on port 80 (HTTP) and/or port 443 (HTTPS). If UFW is not installed, you can install it and configure it with the following commands:

sudo apt install ufw
sudo ufw allow ‘Nginx HTTP’
sudo ufw allow ‘Nginx HTTPS’
sudo ufw enable

7.Adjust the firewall rules based on your specific requirements.

Access Nginx Default Page: Open a web browser and enter your server’s IP address or domain name. You should see the default Nginx welcome page, indicating that the installation was successful.