How to install nginx in Ubuntu

To install Nginx on Ubuntu, follow these general steps:

  1. Open a terminal window on your Ubuntu system.
  2. Update the apt package index by running the following command:
    sql
    sudo apt update
  3. Install Nginx by running the following command:
    sudo apt install nginx
  4. After the installation is complete, start the Nginx service by running the following command:
    sql
    sudo systemctl start nginx
  5. To check if Nginx is running, run the following command:
    lua
    sudo systemctl status nginx

    If Nginx is running, you should see a message that says “active (running)”.

  6. By default, Nginx should start automatically when your system boots up. If it doesn’t, you can enable the Nginx service to start on boot by running the following command:
    bash
    sudo systemctl enable nginx

Now that Nginx is installed and running, you can access the default Nginx web page by opening a web browser and navigating to your server’s IP address. If everything is working correctly, you should see the default Nginx web page.