Digitalocean Install Nginx Ubuntu 18.04

Digitalocean Install Nginx Ubuntu 18.04

Introducing DigitalOcean and Nginx

DigitalOcean is a virtual cloud server provider, allowing users to spin up virtual servers located in various geographical locations throughout the world. They provide an excellent platform for running a website, game server, or any other sort of hosting service. DigitalOcean also makes it easy to install software packages, such as web servers and databases.

Nginx is an open source (free) web server and proxy server, popular in many circles as a lightweight and robust web server. Nginx is used in a variety of applications for web hosting and development, including static sites, video streaming sites, and applications.

In this article, we’ll walk you through the steps for installing Nginx on an Ubuntu 18.04 DigitalOcean droplet. This is a relatively simple process, and you don’t need any previous server administration experience. Let’s get started!

Step 1 — Installing Nginx

The first step to installing Nginx is to make sure that the latest version of the web server is installed on the droplet. We can do this by running the update command:

sudo apt-get update

Next, we’ll install the Nginx web server with the following command:

sudo apt-get install nginx

Once the installation is complete, Nginx should be up and running. You can test this by visiting the IP address of your droplet in a web browser. You should see the default Nginx page which looks like the following:

If you see this page, Nginx is installed and running correctly.

Step 2 — Configuring Firewall Settings

Before we can begin serving content with Nginx, we’ll need to configure our firewall to allow traffic on port 80. By default, Ubuntu’s ufw firewall should be enabled, blocking all incoming traffic. To allow connections on port 80, we’ll need to open this port with the following command:

sudo ufw allow http

You can check the status of the firewall afterwards by typing:

sudo ufw status 

You should see that port 80 is now allowed.

Step 3 — Configuring Nginx

Now that Nginx is installed and our firewall is configured, we’ll need to make some changes to Nginx’s configuration file. Open the file in a text editor with the following command:

sudo vi /etc/nginx/sites-available/default

The configuration file should look like this:

Make the following changes to the configuration file:

  • Change server_name _; to server_name ;
  • Replace /var/www/html; with /var/www/html/public_html;

Save and close the file when you are finished. Then, we can enable our changes by typing:

sudo systemctl restart nginx

Step 4 — Serving Content with Nginx

Now that Nginx is configured and running, let’s test it by creating a web page. Create a directory for your web page with the command

sudo mkdir -p /var/www/html/ public_html

. Next, create a sample page with the following command:

sudo vi/var/www/html/public_html/ index.html

Add the following HTML code to the file and save it:

My First Web Site

Hello World!

Now, if you visit the IP address of your droplet in your web browser, you should see the “Hello World!” page that you just created.


In this article, we saw how to install and configure the Nginx web server on an Ubuntu 18.04 DigitalOcean droplet. We also saw how to create a web page and test it in the browser. Now you are ready to serve content on your Nginx server!

Frequently Asked Questions (FAQs)

Q: How can I make sure that Nginx is running?

A: You can check the status of Nginx by running the following command:

sudo systemctl status nginx

Q: How can I make sure that my firewall is configured correctly?

A: To check the status of your firewall, run the command

sudo ufw status

. This will show you all of the ports that are currently allowed or denied.

Q: How do I create a web page on my server?

A: You can create a web page by creating a directory for it, such as


, and then creating and saving an HTML file in that directory. You can then view the page in your web browser by visiting the IP address of your droplet.

Thank you for reading this article. If you enjoyed reading this article, please check out our other articles.

Leave a Reply

Your email address will not be published. Required fields are marked *