How to Install Nginx on Ubuntu
To install Nginx on Ubuntu, you can follow these steps:
Step 1: Update your package lists by running the following command:
sudo apt update
Step 2: Once the package lists are updated, you can install Nginx by running the following command:
sudo apt install nginx
During the installation, you may be prompted to confirm the installation by pressing ‘Y’ on your keyboard. If any additional packages are required, they will be installed automatically.
Step 3:Â After the installation is complete, Nginx should start automatically. You can verify the status of Nginx by running the following command:
sudo systemctl status nginx
If it’s not running, you can start it with the following command:
sudo systemctl start nginx
If Nginx is running correctly, you should see a “active (running)” message.
By default, Nginx will serve files from the /var/www/html directory. You can open a web browser and visit your server’s IP address (or domain name) to confirm that Nginx is working. If you see the default Nginx welcome page, it means the installation was successful.
Step 5: Enable Nginx to start on boot
sudo systemctl enable nginx