How I set up Linux web server and deployed my static site
Tags: linux, cloud, server, beginners
Published: 2019-05-30 14:51:50

---
title: How I set up Linux web server and deployed my static site
published: true
description: Small description of the steps I took to deploy a web server
tags: #linux, #cloud, #server, #beginners
canonical_url: https://www.halldorstefans.com/how-i-set-up-linux-web-server-deployed-my-static-site/
cover_image: https://images.unsplash.com/photo-1502945015378-0e284ca1a5be?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1650&q=80
---
*Originally published on my blog at [halldorstefans.com](https://www.halldorstefans.com/how-i-set-up-linux-web-server-deployed-my-static-site/) on January 13, 2020*

In this post I'm going to go through the steps I took to deploy a Linux server, make it a web server and deploy my personal site on it.
My main purpose with this exercise is to do a Linux project and learn.
I'll be using DigitalOcean as the cloud provider, but I assume these instructions can be transferred to other cloud providers, although I haven't tried it.
Creating the server and initial setup
This documentation shows how to create the server, or Droplet like DigitalOcean calls it.
I chose an Ubuntu 18.04 image, using the cheapest standard plan and no backups. I didn't see the need for the backup option at this point.
Once the server is up and running, we can start on the initial setup. These steps involve creating another user, setting up a basic firewall and enabling external access.
I would also recommend setting up SSH keys on the server.
Domain and DNS
Since I was setting up a web server in the hope of having a site deployed, I was going to need some domain, so I bought one using Namecheap. You can also buy from GoDaddy or other domain providers.
Then you can create a DNS service in DigitalOcean and then make sure that the domain registrar is pointing to the DigitalOcean nameservers.
Nginx and SSL certificate
Now we are going to make make it into a web server. We can either use Nginx or Apache, and I decided to go for Nginx. No specific reason, just to try it out.
Here we see how to install Nginx and other adjustments. And then secure it with Let's Encrypt.
"Deploying" my site
I'll admit this step is not the most professional :D but I just wanted to get my code to the server as quickly as possible to see if everything was working.
Side thought:
I'm wondering if I should set up some delivery pipeline for it. That off course might be a bit of overhead for such a small project but for the sake for learning, why not?
Ok, back to the deployment.
What I did was that I used FileZilla to move the code from my local computer to the path:
/var/www/example.com/html/index.html
on the server, where instead of example.com in the path I had the domain I bought earlier.
It worked!
Yes, it worked :) I really enjoyed this exercise, and I find it cool to be hosting my site on my Linux server.
Next steps
There are a couple of things that I want to do next, and I'll probably use this site/server as the base.
Linux hardening
Server monitoring and configuration
Create a release/delivery pipeline
Have you tried setting up a web server? Is there something you would do differently?
Do you have any other ideas for next steps?

Thank you for reading. For weekly updates from me, you can sign up to my newsletter.

In this post I’m going to go through the steps I took to deploy a Linux server, make it a web server and deploy my personal site on it.

My main purpose of this exercise is to do a Linux project and learn.

I'll be using DigitalOcean as the cloud provider, but I assume these instructions can be transferred to other cloud providers, although I haven't tried it.

## Creating the server and initial setup

[This documentation](https://www.digitalocean.com/docs/droplets/how-to/create/) shows how to create the server, or Droplet like DigitalOcean calls it.

I chose an Ubuntu 18.04 image, using the cheapest standard plan and no backups. I didn't see the need for the backup option at this point.

Once the server is up and running, we can start on the initial setup. [These steps](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04) involve creating another user, setting up a basic firewall and enabling external access.

I would also recommend [setting up SSH keys](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-1804) on the server.

## Domain and DNS

Since I was setting up a web server in the hope of having a site deployed, I was going to need some domain. So I bought one using [Namecheap](https://www.namecheap.com/). You can also buy from [GoDaddy](https://uk.godaddy.com/) or other domain providers.

Then you can [create a DNS service](https://www.digitalocean.com/docs/networking/dns/quickstart/) in DigitalOcean and then make sure that the [domain registrars are pointing to the DigitalOcean nameservers](https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars#registrar-namecheap).

## Nginx and SSL certificate

Now we are going to make make it into a web server. We can either use [Nginx or Apache](https://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations), and I decided to go for Nginx. No specific reason, just to try it out.

[Here](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04) we see how to install Nginx and other adjustments. And then [secure it with Let's Encrypt](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04).

## "Deploying" my site

I'll admit this step is not the most professional :D but I just wanted to get my code to the server as quickly as possible to see if everything was working.

Side thought:

*I'm wondering if I should set up some delivery pipeline for it. That off course might be a bit of overhead for such a small project but for the sake for learning, why not?*

Ok, back to the deployment. 

What I did was that I used FileZilla to move the code from my local computer to the path, **/var/www/example.com/html/index.html**, on the server, where instead of *example.com* in the path, I used the domain I bought earlier.

## It worked!

Yes, it worked :) I really enjoyed this exercise, and I find it cool to be hosting my site on my Linux server.

## Next steps

There are a couple of things that I want to do next, and I'll probably use this site/server as the base.

- Linux hardening
- Server monitoring and configuration
- Create a release/delivery pipeline

Have you tried setting up a web server? Is there something you would do differently?

Do you have any other ideas for next steps?

---

Thank you for reading. For weekly updates from me, you can sign up to my [newsletter.](https://email.halldorstefans.com/)