Comment on page

Setup a server

To deploy your experiments to the web, you'll need a server and a domain name. We've outlined how to create each of these in the following sections. There is also a 20-minute video tutorial if you prefer to follow along that way.
Setup your server: Create a server and a domain name

Create a server

The first step is to create a new VPS (virtual private server) to host your experiments. You can purchase cloud servers from many companies – AWS, Google Cloud, Microsfot Azure, IBM CLoud, Linode, and more – but we recommend Digital Ocean. Students can recieve a $100 Digital Ocean credit through the GitHub Student Developer Pack. Others can use our referral link for a $100 credit.
On Digital Ocean, virtual servers are called droplets. To create a new one, login to Digital Ocean and click Create droplet. Use the following setup options (you can leave anything else blank or as defaults):
  • Choose an image: Under Marketplace, choose the Docker image.
  • Choose a plan: The $5/mo option will be plenty for most people.
  • Choose a datacenter region: Choose somewhere close to you.
  • Authentication: If you have SSH keys, use them. If not, choose the password option.
  • Finalize and create: Choose a hostname. We recommend your domain name.
Once your droplet has been created, make sure it has docker, docker-compose and git installed. To check, you can ssh into your server (or login with your password)
and run the following commands to check for each service.
docker -v
docker-compose -v
git --version
If any are missing, destroy the droplet and start again. Don't worry if you have to try this a few times to get it right. Even seasoned developers make mistakes. If your server has all three, hooray! You are ready for the next step.

Create a domain name

The next step is to create a domain name for your server. Namecheap.com is a good option for registering domain names and the Student Developer Pack provides credits.
Select a domain and follow the steps to register it. On the dashboard, you'll want to change your domain's NAMESERVERS to Custom DNS and enter digital ocean's three name servers:
  • ns1.digitalocean.com
  • ns2.digitalocean.com
  • ns3.digitalocean.com
Once you have registered your domain and changed its nameservers, head back over to Digital Ocean to add it there. Select Networking from the sidebar and then the Domains tab.
Finally, you need to create two A records. Select the domain and then under Create new record, select A. For each of the following:
  • @ that point to your server's IP address.
  • * or wildcard that points to your server's IP
Now, when someone visits your domain (@) or any subdomain of your domain (*), they will be sent to your server's IP address.

Advanced moves

Add a user to your server

To add a user to your server, ssh in as root
Add the user and set their home directory
useradd -d /home/username username
And add them to the sudo group
usermod -aG sudo username
create an ssh directory for them, to hold their ssh keys
mkdir -p /home/username/.ssh
And then paste their authorized keys into an authorized_keys file
nano /home/username/.ssh/authorized_keys
Here is how to generate an ssh key if you need one!