Those who are into web development, hosting servers, and managing website traffic might be familiar with Nginx. It is a bit similar to Apache, as it is an open-source software for web serving, proving, caching, and other tasks. If you're running a great Linux distribution like Ubuntu, you can get started with Nginx in just a few steps. We're here to help explain how you can install it by using a few terminal commands.

How to install Nginx on Ubuntu

As with most of these tasks and like installing some of the best Linux app alternatives, you need to open a terminal session with Ctrl + Alt + T. Once a terminal is open, you can proceed with installing Nginx step by step with these commands. Nginx is available through Ubuntu's default repositories. We'll also go through opening up your Ubuntu firewall to allow Nginx access to network traffic.

  1. Update Ubuntu's packages with the command: sudo apt update
  2. Install Nginx with the command: sudo apt install nginx
  3. Enter your password, then confirm the install with y
  4. Once installed, you need to adjust the firewall settings on Ubuntu. Use the command sudo ufw app list.
  5. You'll see a readout of several application profiles, as seen below.
  6. Allow Nginx to access traffic over port 80 with the command sudo ufw allow 'Nginx HTTP'
  7. Confirm the change with the command sudo ufw status

Once you finish the installation process, you can confirm that Nginx is running. Just use the command systemctl status nginx. The process isn't done just yet, though. We have some additional tips for you in the section below.

Additional tips for Nginx on Ubuntu

Now that you've completed your install of Nginx on Ubuntu, there are some additional things to keep in mind. You might want to request a page from Nginx to confirm things are working before you dive any deeper. Do this by going to your web browser and typing localhost or 127.0.0.1 into the address bar. After that, you can use some commands to manage your server. We're diving into these for you below.

Importantly, if you want to enable this to start at boot, use the command sudo systemctl enable nginx. To stop a web server, you can use the command sudo systemctl stop nginx. To start a server use the command sudo systemctl start nginx. If you want to make configuration changes and reload the service, use the command sudo systemctl restart nginx. To make configuration changes but not drop the connection, you can simply reload with the command sudo systemctl reload nginx.