Projects

Tutorial

Build a Linux-based Web Server on DigitalOcean

March, 2020

Will Sheldon, painting

Herewith is the workflow I use to build a new Web server on the cloud, DigitalOcean's specifically, using a Linux distribution and the Apache Web Server. I'm writing this chiefly for my own documentation, though I hope it could be handy for others. This assumes a basic knowledge in Linux and associated software.


Get a Running Virtual Machine


As I said, I'm setting this server up on DigitalOcean, where you can procure "droplets" or virtual machines for about $5/month. After setting up an account on DigitalOcean, go to your home page.

In the DO current user interface, look for the Droplets menu item then looking for the Create button (upper right hand side). You will be given a range of distribution, Ubuntu, Debian, Fedora, etc. I go with CentOS because it tracks well with Red Hat Enterprise Linux, the closest to a corporate standard for Linux. Each version of CentOS is now supported with maintenance bug fixes for 10 years (Woot!). As of this time, the latest CentOS is 8.2 DigitalOceans droplets

I picked the cheapest performance option, for $5/month. This comes with a 25GB solid state disc, 1,000GB monthly transfer and a single CPU, with 1GB of working memory. Some of the fancier "Performance" models look sleek, but let's stick to the basics now. You can also add a variable amount of block storage if one of the preset droplet configurations doesn't have t\he right amount. Other options include picking a data center region. For latency's sake, pick the one closest to where you are located (NYC for me).

For a host name, I usually go with what domain name I will assign it. In this case, it will be joabj.info, for joabj.info, which will be the domain name for my test site.

Keys to the Website<

Next, set up a SSH key to secure your droplet. You can do it from the command line in Linux or Mac via SSH, or by using PuTTY in Windows. Note: For simplicity's sake, you should do this from the computer you are planning to access the Droplet from.

With SSH on the command line, you kick off the process by running ssh-keygen, a package within PuTTY, to generate a keypair. The program will give you the option to create keys in a number of different formats. Use one that will be accepted by DigitalOcean--SSH-RSA or SSH-DSA, which are fairly identical, at least functionally. (Note: If you use PuttyGEN on Windows to generate a key set, you will have to reload the the private key to get the public key in the right format for DigitalOcean -- just opening the file and copy and pasting will result in an error message.)

For more background on how SSH is used to log in to systems, see this post.

You'll be prompted for a keypair name -- I used joabj-info. For extra security, you can create a passphrase that you'll be asked for whenever you log in. After this process, you will get a file with the public key in the /ssh file (mine was joabj-info.pub).

to be continued...

Back