Announcement

Collapse
No announcement yet.

How to Install Nginx on Ubuntu 24.04

Collapse
X
Collapse
  •  

  • How to Install Nginx on Ubuntu 24.04


    Nginx stands out for its higher performance and scalability among the available web servers. Nginx is open-source, and you can use it for different activities on your Linux system. In Ubuntu 24.04, you can install Nginx by sourcing it from the default repository. Once installed, configure your firewall and start using Nginx. This post shares the details of every step you should take. Read on!
    Step-by-Step Guide to Install Nginx on Ubuntu 24.04

    To install Nginx, ensure you have access to your system with sudo privileges and access to the terminal. With that, the steps below will guide you through everything you should do to install and configure your firewall to start using Nginx. Follow along!

    Step 1: Update the Repository

    in Ubuntu 24.04, Nginx is available in its default repository. As such, you won’t have to add its repository. Before installing this Nginx version, let’s ensure we get the latest version by updating the package index.

    $ sudo apt update




    Step 2: Install Nginx via APT

    After refreshing the Ubuntu repository, execute the install command below to fetch and install the Nginx package. Ensure you confirm the prompt.

    $ sudo apt install nginx




    Confirm that Nginx has been installed by running the below command to display the installed version.

    $ nginx -version




    We’ve installed Nginx 1.24.0.

    Step 3: Enable and Start the Nginx Service

    Before we can use Nginx, we must start the Nginx service. Instead of starting it every time you want to use it, setting Nginx to start at boot time is better. To do so, enable the Nginx service and restart Nginx using the commands below.

    $ sudo systemctl enable nginx

    $ sudo systemctl restart nginx




    Next, check the Nginx service to ensure that it’s active (running).

    $ sudo systemctl status nginx




    Step 4: Configure the Firewall

    Although the firewall automatically detects Nginx and allows its connection, we must ensure it registers it. You can also specify a different rule to use with Nginx.

    For this guide, we don’t want to give Nginx full access. Instead, let’s specify that we only want to connect via HTTP. To save this configuration, execute the following command.

    $ sudo ufw allow ‘Nginx HTTP’




    You can also give it HTTPS access, or if you want to allow HTTP and HTTPS, create a Nginx Full rule.

    With our rule added successfully, let’s view the firewall status to verify further that we have our rule added correctly. Check the firewall status using the command below.

    $ sudo ufw status




    Step 5: Verify Nginx Works

    A quick way of confirming that your Nginx installation was a success is by opening the Nginx landing page. You can do this in two ways. The first option involves opening your web browser and accessing your web page. For instance, if using localhost, we would open the site: http://localhost

    You will get an Nginx welcome page confirming that Nginx is all set and ready for use.



    Alternatively, you can visit the same web page using curl and check the output. If the output shows the same welcome message, your installation was successful.

    $ curl 127.0.0.1




    Conclusion

    Nginx is an open-source web server that can be installed and used on Ubuntu 24.04. The Nginx package is available from the Ubuntu repository. To install it, use APT. Next, configure your firewall to allow traffic via Nginx. We’ve discussed each step, and with this guide as a reference, you can install Nginx on Ubuntu 24.04.





    More...
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    There are no tags yet.

    Latest Articles

    Collapse

    • What is Shebang: Bash Script Header on First Line?
      by Kasimba
      As Linux enthusiasts, we all come across bash scripting as an essential part of the Linux system. However, many Linux users don’t know why the first line of the bash script contains #!. So this combination of # and ! is called shebang or shebang.
      Although shebang looks like a bash script header, it initially instructs the system about interpreters to execute the script. This concept feels a bit complicated, but that’s not true, as this guide is all about the shebang: bash script header....
      Yesterday, 07:59 PM
    • Bash Script Loops Examples
      by Kasimba
      A loop in programming is a control structure that allows a specific code to be executed repeatedly until a condition is met. This process is repeated until no further action is required. Loop allows you to repeat the desired set of instructions numerous times to attain the desired outcome. These recursions can be useful for all tasks that require repetitive operations or when working with data collections.
      In this article, we will explore the meaning, types, and examples of loops, further...
      Yesterday, 07:59 PM
    • How to Install NVIDIA GPU Driver on Fedora 40+ KDE 6 Spin on Wayland
      by Kasimba
      Installing the NVIDIA GPU driver is the first thing you will want to do after installing Fedora 40 on your computer. Fedora 40 comes with different spins (desktop environments) and the latest software. Wayland display server (which will replace the X11/Xorg display server completely one day) is the default on some of the Fedora 40 spins. One of the most awaited Fedora 40 spin is the KDE spin. Fedora 40 KDE spin comes with the KDE Plasma 6 desktop environment which supports only the Wayland display...
      Yesterday, 07:59 PM
    • How to SSH Into Docker Container
      by Kasimba
      Administrators commonly use SSH to access and operate remote servers and devices, including a Docker container. When you connect to any device using SSH, you can run commands, access its files, and perform multiple other tasks. You can also use the Docker container as a hypervisor image that can run applications. For example, a software developer can create a Docker container image to package the software.

      Hence, a Docker container image package software with all the dependencies and...
      Yesterday, 01:12 PM
    • How to SSH Into EC2 Instance
      by Kasimba
      EC2 is a service provided by Amazon Web Services (AWS) that lets you rent virtual servers (known as instances). In these instances, you can leverage virtual machines to develop, test, deploy, and manage computer applications.

      SSH is an incredible utility for accessing and managing Amazon Elastic Compute Cloud (EC2) instances. With SSH, you can operate a remote device, access data, execute commands, troubleshoot issues, and more. Although you can easily SSH into an EC2 instance, many...
      Yesterday, 01:12 PM
    • How to Tunnel Web Traffic Through SSH for Secure Browsing
      by Kasimba
      Nowadays, an uncountable number of cyber attacks, scams, and data theft occur every single day. This makes it necessary for users to look for ways to secure their data. After all, it is better to take precautions than to experience a guilt trip. Fortunately, SSH offers tunneling, which channels internet traffic to your local system via a remote system.

      Meanwhile, this transmission encrypts incoming and outgoing network traffic on your local Linux device, ensuring the system’s security....
      Yesterday, 05:01 AM
    Working...
    X