Your First Server
We will do this as an interactive session as the interfaces are different for each provider and they change over time. There are a variety of cloud providers including AWS, Azure and DigitalOcean. Let me know your preference for this. DigitalOcean is beginner-friendly, however the powerful machines are on AWS and Azure.
Objectives
We are going to:
- Set up a server on a cloud provider
- Perform initial server setup
- Deploy a website on the internet using nginx
What you will need
- Credit card
- Cloud provider account
- SSH Key from the previous section
Free tiers
Most cloud providers offer a free tier for new users. This is a great way to get started with cloud computing without incurring any costs. The free tier usually includes a limited amount of resources for a limited time period. For example, AWS offers a free tier for 12 months with limited resources.
Provisioning a server
We will walk you through the process of provisioning a server on a cloud provider.
- Sign in to your cloud provider account.
- Navigate to the dashboard.
- Click on the
Create Instance
orCreate Server
button. - Choose the operating system you want to use. We recommend using Ubuntu as it is the most popular choice.
- Choose the server size. The free tier usually offers a small server with 1 CPU and 1GB of RAM.
- Ensure the server location is set to the UK.
- Choose the SSH key. You can use an existing SSH key or create a new one. We recommend creating a new SSH key for each server.
- Click on the
Create
button.
Initial server setup
Once the server is created, you will need to perform some initial setup steps.
1. SSH into the server using the command below
Bash | |
---|---|
Replace <server-ip>
with the IP address of your server.
2. Update the server
Bash | |
---|---|
3. Install build tools
Bash | |
---|---|
4. Secure the server
Configure the firewall to only allow SSH connections:
5. Deploy a static website
Create a new directory for the website:
Bash | |
---|---|
Create a simple HTML file in the /var/www/html directory:
Copy this into the file:
/var/www/html/index.html | |
---|---|
Configure nginx to serve the website:
Bash | |
---|---|
Set up DNS records to point to the server IP address.
Visit the website and you should see the "Hello, World!" message.
6. What next?
Things you can try:
- Set up SFTP and upload files to this server
- Connect VSCode to this remote server and run jupyter notebooks on it
- Deploying more complex web applications
- Set up this machine as a head node for NextFlow
Warning
Remember to shut down your server after this to avoid unnecessary charges.
Why did we set up a server from scratch?
Going through this exercise is useful because these concepts will be directly applicable when we move onto more advanced topics of containerization and infrastructure as code. Deploying this by hand will help you understand the underlying concepts of how servers work and how to configure them.
This exercise demonstrates the importance of environment management in creating reproducible workflows. In the past, it was common for the issue of "it works on my machine but not yours" to arise.
If you revisit the chapter on setting up python and python environments, you will see that we are essentially dealing with the same problem here, with a slightly different context.
Info
What we did in this tutorial in setting up the server is also known as ClickOps. This is where you manually click through the interfaces to set up the server. The next level to this is to automate the process of deploying servers using Infrastructure as Code (IaC) tools like Terraform and Ansible. If you are setting up more complex cloud infrastructure, you may wish to pick up these technologies.