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.
Conclusion
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
/var/www/html/public_html
, 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.
Related Posts:
Reverse Proxy Nginx Ubuntu 18.04 Reverse Proxy Nginx Ubuntu 18.04 Introduction Reverse Proxy is a type of proxy server that forwards requests to another server. It is mainly used by web servers, such as Nginx,…
Lets Encrypt Nginx Ubuntu 14.04 With Nginx Conf Custom Let's Encrypt Nginx Ubuntu 14.04 with Nginx Conf Custom Introduction to Nginx Conf Custom Nginx Conf Custom is an open source solution for hosting web applications on Ubuntu 14.04. It…
Deploy Laravel Nginx Ubuntu 18 Deploy Laravel Nginx Ubuntu 18 Intro to Laravel Laravel is a free, open-source, Model-View-Controller (MVC) web framework written in PHP. It has become one of the most popular web development…
Ubuntu Install Web Server Nginx Ubuntu Install Web Server Nginx Step 1: Install the Nginx Package The first step when installing Nginx on Ubuntu is to install the Nginx package from the Ubuntu repository. This…
Ubuntu Server Postgresql Nginx Php Ubuntu Server Postgresql Nginx Php Introduction Optimizing your server is one of the most important steps you can take when it comes to running a successful website or application. It…
Install Wordpress On Ubuntu 18.04 Nginx Install WordPress On Ubuntu 18.04 Nginx Introduction To Ubuntu And Nginx Ubuntu is a popular open-source operating system which has gained immense popularity over the years. It is easy to…
Instal Nginx 1.5.0 Installing Nginx 1.5.0 Overview of Nginx Nginx is a web server that is used to serve web content quickly and reliably. It is popularly used in asynchronous web applications, due…
Ubuntu Server18 How To Enable Nginx Pdo Mysql Ubuntu Server18: How to Enable Nginx Pdo Mysql As a developer, you may have heard of Nginx, PDO, and MySQL – all are essential components of web applications. Nginx is…
Install Nginx Phpmyadmin Centos 7 Install Nginx Phpmyadmin Centos 7 What is Nginx? Nginx is a web server that is used in Linux-based operating systems such as Centos 7. It is designed to handle high-traffic…
Nginx Wordpress Ubuntu 18.04 Nginx Wordpress Ubuntu 18.04 Introduction to Nginx Nginx is a web server software for hosting websites and applications. It is open-source and highly configurable, making it a popular choice for…
Nginx Command Not Found Ubuntu Nginx Command Not Found Ubuntu What is Nginx? Nginx (pronounced as Engine X) is an open source web server created to handle high traffic network applications, replacing traditional web servers…
Install Nginx 1.17 Centos 8 Install Nginx 1.17 Centos 8 Introduction to Nginx Nginx is one of the most popular web servers in the world. It is reliable, free, and open source software. It is…
Install Nginx Ubuntu 16.04 For Odoo Install Nginx Ubuntu 16.04 For Odoo Install Ubuntu Server 16.04 Before we can install Nginx for Odoo we need to install Ubuntu 16.04 on our server. Ubunutu 16.04 is still…
Install Phpvirtualbox On Ubuntu 12.04 Nginx Install PHPVirtualbox on Ubuntu 12.04 Nginx What is PHPVirtualbox? PHPVirtualbox is a web-based management tool designed to assist the user in creating and managing virtualized environments. It is developed, maintained…
Nginx Php Fpm 7.2 Nginx Php Fpm 7.2 Introduction to Nginx and PHP-FPM Nginx is an open-source web server, reverse proxy server, and load balancer. It is known for being lightweight and fast, and…
Install Paid Ssl Nginx Ubuntu 18.04 Install Paid SSL Nginx Ubuntu 18.04 What Is Nginx? Nginx is an open-source web server and reverse proxy used in many applications worldwide. It is a lightweight, high-performance server that…
Laravel 5.5 Configure Nginx Laravel 5.5 Configure Nginx Introduction To Nginx Nginx is a web server software often deployed as a reverse proxy. It is open-source and available to download for free. Nginx has…
Tutorial Start Nginx Ubuntu Webserver Tutorial Start Nginx Ubuntu Webserver Step 1: Prerequisites Before we start configuring Nginx as a web server on Ubuntu, we need to make sure we have the following prerequisites: A…
How To Install Nginx Maridb 10 On Ubuntu 16.04 Lts How To Install Nginx Maridb 10 On Ubuntu 16.04 Lts Step 1 — Installing Nginx The first step in installing Nginx and MariaDB 10 on Ubuntu 16.04 is installing Nginx.…
Dgitalocean Nginx React Assets Dokcer DigitalOcean Nginx React Assets Docker Pengenalan digitalocean Nginx React Dan Assets Docker DigitalOcean merupakan salah satu penyedia layanan web hosting terbesar di dunia yang dilengkapi pula dengan virtual private server,…
How To Install Flask Nginx On Ubuntu 1604 How To Install Flask Nginx On Ubuntu 1604 Introduction Flask is a web application framework based on Python. It is highly useful for web developers due to its flexibility and…
Install Webuzo Without Conlicting Nginx Centos 7 Install Webuzo Without Conlicting Nginx Centos 7 What is Nginx? Nginx is an open-source web server that was created and released in 2004. It is known for its speed, stability,…
How To Install Wordpress On Nginx How To Install Wordpress On Nginx Introduction If you’re looking to start your own website or blog, probably the easiest and most popular platform to choose is WordPress. WordPress is…
Install Phpmyadmin For Nginx Debian 8 Install Phpmyadmin For Nginx Debian 8 Introduction The Nginx web server popularly known as Nginx is a lightweight web server written in C programming language. It is an open source…
Openldap Slapd Php Nginx Ldap Centos Openldap Slapd Php Nginx Ldap Centos What is OpenLDAP OpenLDAP is an open-source implementation of the Lightweight Directory Access Protocol (LDAP) and is offered by the OpenLDAP project. OpenLDAP is…
Webmin Module For Nginx Web Server Webmin Module For Nginx Web Server Introduction to the Nginx Web Server Nginx is an open source web server and reverse proxy that offers powerful performance in a lightweight package.…
Install Nginx Ubuntu 18.08 Local Install Nginx on Ubuntu 18.04 Local Installing Nginx on Ubuntu 18.04 can be accomplished quickly and in several different ways. Depending on your needs, some methods may be better suited…
Install Nginx And Php On Ubuntu Install Nginx And Php On Ubuntu A Comprehensive Tutorial to Install Nginx And Php On Ubuntu Nginx and PHP are two of the most popular web server and scripting language…
404 Not Found Nginx Ubuntu 404 Not Found Nginx Ubuntu What is 404 Not Found Error? The 404 Not Found error is one of the most irritating status codes that can appear when someone attempts…
Install Nginx Phpmyadmin Ubuntu 18.04 Install Nginx Phpmyadmin Ubuntu 18.04 Introduction to Nginx, PHP, and Ubuntu Nginx is an open-source, high-performance web server written in C and used to serve static and dynamic webpages. It…