Install Nginx on Ubuntu 22.04

The powerful web server and reverse proxy server Nginx lets you host and manage web applications. We will show you how to install it on an Ubuntu 22.04 server.

The powerful web server and reverse proxy server Nginx is known for its speed, stability and flexibility. The initial installation on Ubuntu 22.04 is quite simple – just follow the six steps below.

How to: Nginx install on Ubuntu 22.04

Step 1: Update your system

We recommend that you first update your Ubuntu 22.04 system before you start the installation. This will ensure that you have the latest software packages. To do this, open the terminal and run the following commands:

sudo apt update
sudo apt upgrade

Enter your password when prompted and confirm the installation of the updates.

Step 2: Install the software

After your system is upgraded, you can install Nginx using the following command:

sudo apt install nginx

When prompted to confirm the installation, simply press “J” and “Enter” to continue. Nginx and all required dependencies will be downloaded and installed by the package manager.

Step 3: Start and activate the service

Once the installation is complete, launch the application with the following command:

sudo systemctl start nginx

To ensure that the software is started automatically at system startup, enable the service with this command:

sudo systemctl enable nginx

Step 4: Check the Nginx installation

Open your web browser and enter the IP address of your server or your domain name. Now you should see the default Nginx welcome page confirming the successful installation.

Step 5: Firewall configuration

If you are using a firewall on your server, you must open the HTTP port (port 80) so that the web server can be reached. Use the following commands to do this:

sudo ufw allow 'Nginx HTTP'
sudo ufw enable

Step 6: Configure your website

Now that Nginx is installed and ready to use, you can add your website configuration. The configuration files for Nginx are located in the directory /etc/nginx. You can create your site configuration in the file /etc/nginx/sites-available/your-site and then create a symbolic link to the folder /etc/nginx/sites-enabled/ to activate the configuration. Do not forget to restart Nginx after each configuration change:

sudo nano /etc/nginx/sites-available/your-site
sudo ln -s /etc/nginx/sites-available/your-site /etc/nginx/sites-enabled/
sudo nginx -t

sudo systemctl reload nginx

Ready to go!

Congratulations, web development on your Ubuntu 22.04 server can now begin! Remember to customize your Nginx configuration according to your requirements.