Some Background
This past Summer, I was lucky enough to spend the better part of a week at a nice house on a small lake with some family (parents + 3 siblings and their family) and our kids (5 kids between 11 and 6) were obsessed with playing local co-op Minecraft with each other.
While I know that Microsoft sells access to Minecraft Realms of $8.00 a month or so, I wondered what it would take to host it on AWS. So I did a little bit of digging and discovered some guides to hosting a Bedrock Minecraft server on Amazon Lightsail.
AWS itself has posted a guide to deploying a Java based Minecraft server on Lightsail but that would not work with the assorted iOS and Android tablets running the Bedrock version. So I decided to modify the instructions and try to get the bedrock version running.
One of the nice things about Amazon Lightsail is that you can budget for them due to their pricing models.
Start the server and install Minecraft
For my minecraft server I went with the smallest instance because it was free for a month and I could always take a snapshot of my instance and upgrade if I need to. I set everything up with OS only on Ubuntu 18.04 and created the instance with the Launch Script that will follow.
Note: you do not need #!/bin/bash or anything like that in the launch script box before your commands. Additionally, everything in here will be run as root so there is no need for sudo or elevation of privileges here.
Launch Script
apt-get update
apt-get install -y unzip
cd /home/ubuntu
wget 'https://minecraft.azureedge.net/bin-linux/bedrock-server-1.16.40.02.zip'
unzip bedrock-server-1.16.40.02.zip -d /home/ubuntu
echo "LD_LIBRARY_PATH=. ./bedrock_server" > run.sh
chmod +x run.sh
apt-get -y upgrade
Explanation of the script
apt-get update
This command will update the list of available packages for your ubuntu box. They are not installed until 'upgrade'
apt-get install -y unzip
This will install the unzip utility we will need to unzip the Minecraft server download.
cd /home/ubuntu
This will navigate to the home directory where you find yourself when you SSH in to the server.
wget 'https://minecraft.azureedge.net/bin-linux/bedrock-server-1.16.40.02.zip'
This will download the bedrock server from Microsoft. This is the current version as of me writing this (10/25/2020). You should replace this with whatever is the current version at Minecraft.net by right clicking on the "Download" box and copying the link to your clipboard. Replace the link above (and modify the file below).
unzip bedrock-server-1.16.40.02.zip -d /home/ubuntu
This will use the utility you previously installed to unzip your download into your ubuntu folder.
echo "LD_LIBRARY_PATH=. ./bedrock_server" > run.sh
This will generate a script that can start the server.
chmod +x run.sh
This will make that script executable.
apt-get -y upgrade
This will begin to upgrade all of the packages that the 'update' command identified as upgradable. The reason that this is not right after the update command is that it will fail part of the way through because it will pop up a GUI input that can't be skipped over with the -y attribute. But the package that we need upgraded to get Minecraft to work happens so 🤷. I would recommend that you run sudo apt-get -y upgrade
on your own, but maybe get that first game of Minecraft in first!
Note: it takes about 30 seconds for the instance to show as running, 60 seconds to be able to SSH into it, and about 120 seconds for the script above to (kinda) complete. So hold your horses and take care of the networking steps while you wait!
Networking
Once your instance enters the 'running' state and turns orange, click on the name or the hamburger menu and select 'manage.'
Click on the Networking tab and enter the rules to allow traffic to the ports the server is listening to. The Bedrock server listens to 19132 by default (and it is auto entered in clients) but you can change that if you choose later. Make a rule to allow UDP traffic to this port.
Lets Play!
To start the server you will want to SSH into it. To do that click on Connect at the top and hit that big orange Connect using SSH button.
Once in, verify that the script ran by entering ls
If it has been 2 minutes from when you initialized the instance, everything should be in order, but you can check by starting up the Minecraft server and seeing if there are any errors.
Manually run the shell script by entering:
./run.sh
If it gives you an error, wait a few more seconds and try again. If everything is working, you will get the following output:
Wahoo!! You can now join this world by entering the public IP address on the 'Connect' page into your Minecraft client.
Extras!!
Allow the server to run in the background forever
As it stands, the Minecraft server will shut down if you enter Ctrl+c or the SSH window times out or closes. This is not optimal. To run the server windowless and allow the SSH connection to close, run the shell script like this:
nohup ./run.sh &
Edit Game Properties
The default server is called 'Dedicated Server' and the game is a survival game blandly named 'Bedrock Level.' These properties, and many more, are stored in the server.properties file. Edit it using vim or your editor of choice. A guide can be found here.
A note about Amazon Lightsail
Amazon Lightsail works on a burst model.
You start with some burst credit, but as you utilize the Minecraft server, you could run out and gameplay could suffer. I found that this wasn't too much of a problem for my use case because once the vacation ended, the ability for the kids to coordinate time to play together was reduced and allowed the credits to fill up to the point where there were plenty when they did get together. Of course, a larger instance IS also an option. See what is right for you!
Top comments (2)
This was just the tutorial I needed, thank you!
Great article!