How To Make This Website - Part 2: Spinning Up a Server
What's a Server?
If you read Part 1 then you already know a server is not a machine, but an instance of software running on some machine. There are many types of servers, but in our case we need an http server because http requests and responses are the language of the World Wide Web (not the Internet!). You may have heard of some http servers like Apache or lighttpd. Nginx is the http server software that I chose, simply because I've worked with it before and I found it much simpler than Apache.
Building an Operating System (OS)
When you tell your computer to do something, the operating system is the thing that does it. A new Linode instance does not having an operating system by default, but we need one to run the server. I chose Arch Linux because I've worked with it before and I enjoy using bleeding-edge software. If this site was sensitive at all then I'd probably use Debian. But this is for fun and for showing off.
Visit Linode, make sure you're signed in, and take a look at the Linode Manager page. Click on the instance that needs an OS. This should land you at the Dashboard for that instance. Find and click "Deploy an Image". Choose Arch Linux in the Image drop-down menu and create a strong root password. I leave the Disk Size and Swap Disk values as defaults; no need to overthink this step for a simple static website. Now hit Deploy!
This will take you back to the Dashboard, but it looks a little different now: there are disks, host jobs in the queue, and a new configuration profile. We're ready to boot this puppy up, so queue up the Halt and Catch Fire intro and smash that Boot button.
Once it's completely booted (watch the Host Job Queue!) visit the Remote Access tab. Here you'll find all the information necessary for ssh-ing into your new OS. I assume you can achieve that on your own, and are now ssh-ed in.
Stop Living Dangerously
The first time you log into your new OS you have to do so as
root. This is okay for very specific tasks, but take it from
someone who ran
# rm -rf * /somethingdumb as root from inside
/ (DON'T DO THIS!): you want a non-root user and
sudo as fast
sudo gives normal users the power of
root with some
protection. Every Linux user should have a grasp of its importance
and how to use it. First update your system with
# pacman -Syu
which may take a few minutes. Now install
-Syu sudo. This allows any user in the "sudo" group to use
so go ahead and create that group with
# groupadd sudo. Run
visudo which will open up the
sudo configuration for editing
vi. Find and uncomment (remove the
#) this line near the
# %sudo ALL=(ALL) ALL
: to enter "command mode", type "wq" which means "save
and quit", and press
Enter. Thankfully you don't ever have to
endure that torture again.
Make a New User
This is the account you will use for everyday tasks. Simply run
useradd -m -s /bin/bash -G sudo your_username replacing
your_username with your choice. All at once this command creates
a user called
your_username, gives that user a home directory at
/home/your_username, adds that user to the "sudo" group, and sets
that user's default shell to
# passwd your_username to set a passwd for your new
account. You're done! Run
# exit to quit the ssh session and run
$ ssh email@example.com to log back in under your new
Secure the Server
You can, and should, go a lot further toward securing your
server. For instance, in its current state bruteforce attacks on
root password are still viable. Start your journey with
Linode's official documentation on the subject.
Okay, you're all logged in with a brand new username armed with the
sudo. Simply run
$ sudo pacman -Syu nginx to
install Nginx. Now run
$ sudo systemctl enable nginx so that nginx
starts running at boot time in the future. For right now though we
need to start nginx manually with
$ sudo systemctl start
nginx. You can check on it with
$ systemctl status nginx if you
get worried or need to debug.
Typing your host's IP address into your browser's address bar should take you to the default nginx page served up thanks to your new host! It looks like this.
If enough time has passed and you did Part 1 correctly, then
should take you to the same page. Make sure to test both with and
www; one may work before the other. In my experience if
two hours have passed and nothing works then there's a good chance
you did something wrong in Part 1. If 24 hours has passed, you
almost definitely messed up Part 1. If 48 hours has passed then
you absolutely 100% messed up Part 1.
By now you have a cloud host (Linode instance) running an OS (Arch Linux) which is running an http server (Nginx) which is responding to http requests with its default stuff. In Part 3 we will configure nginx, put up a barebones website, and add SSL!