My 10-year-old son, Jack, is a huge fan of Minecraft. If you let him, he'd play all day, skipping meals and having a blast. It's most fun to hear him playing with his sister or his best friend. I'm amazed it's captured his attention for so long; well over two years. Both my kids loved it when Scott Davis taught a Devoxx4Kids Denver class on Server-side Minecraft programming.
We haven't had any Devoxx4Kids Denver workshops this year, but that's about to change. First of all, I'm happy to announce we're working with the Rocky Mountain Oracle Users Group to have a Day of Family Coding Fun at Elitch Gardens this Friday. There will be a workshop on Raspberry Pi and I'll be doing a demonstration on how to setup a Minecraft Server in the cloud. Next weekend, we'll be doing a more in-depth Minecraft Workshop at Devoxx4Kids Denver. If you'd like to join us please RSVP. Since having your own Minecraft Server is a fun thing for kids, and useful for parents, I figured I'd document how to do it here.
First of all, let me say that I'm standing on the shoulders of giants. When I first setup a Minecraft server, I used Ben Garton's Setting up a free Minecraft server in the cloud - part 1 as well as part 2 and 3. I also found Aaron Bell's How to run a Minecraft server on Amazon EC2 to be quite useful.
Without further ado, here's you how to setup a Minecraft Server on Amazon Web Services (AWS) in 2015!
Step 1: Signup for AWS and Create an Instance
- Navigate to http://aws.amazon.com/, and click "Sign In to the Console" using your Amazon account. If you don't have an AWS account, you'll need to create one and specify a payment method.
Click on EC2 in the top left corner, then Launch Instance on the following screen.
Select Amazon Linux.
Choose an Instance Type of t2.micro, then click Next: Configure Instance Details.
- You don't need to configure anything on the next screen, so click Next: Add Storage. Storage settings don't need to be changed either, so click Next: Tag Instance.
On the Tag Instance screen, assign a name to your server. I chose "Minecraft Server". Click Next: Configure Security Group to continue.
This step is important because it opens a Minecraft port that allows players to connect. Create a new security group with name Minecraft and description Ports for Minecraft. Click Add Rule, specify Custom TCP Rule, Port Range 25565 and Source Anywhere. Note that you can also lock down your instance so only certain IPs can connect. Click Review and Launch to continue.
You'll be warned about allowing any IP address on the following screen. Click Launch to continue.
You'll be prompted to create a new keypair. I chose "minecraft" for my key pair name. Click Download to download your key pair.
I executed the following commands to move this key to a location on my hard drive and locked it down so the public can't view it.
mv ~/Downloads/minecraft.pem ~/.ssh/. chmod 400 .ssh/minecraft.pem
Click Launch Instances to continue. You should see something like the following screen.
Click on the instance name and copy/paste the Public IP. You'll want to write down this IP address since you'll need it later, and you'll also want to send it to friends so they can join.
Execute the following command with this IP to connect to your server. Type yes when prompted to continue connecting.
ssh -i .ssh/minecraft.pem ec2-user@your-public-ip
You'll likely be told there's a number of updates to install; run sudo yum update to install them.
Step 2: Install a Minecraft Server
From your Linux prompt, type the following commands to create a folder and copy the latest version* of the Minecraft server into it.
mkdir MinecraftServer cd MinecraftServer wget https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar
* Check http://www.minecraft.net/download to find out the latest version number and change the above command appropriately.
- Create a symlink to the downloaded JAR so you can keep the same launch command, regardless of version.
ln -s minecraft_server.1.8.8.jar minecraft_server.jar
Launch your server using the following command:
sudo java -Xmx1G -Xms1G -jar minecraft_server.jar nogui
You should see ouput like the screenshot below, prompting you to agree to the EULA.
eula.txtby running sudo vi eula.txt and changing "eula=false" to "eula=true". If you're unfamiliar with vi, the following instructions will help you edit this file after you've opened it.
- Type "/false" followed by [Return]
- Type "xxxxx" to delete "false"
- [Shift+A] to go to the end of the line
- Type "true"
- Hit [Esc], then type ":wq" to save the file
Run the sudo java command again (hitting up arrow twice will retrieve this command from your history). This time, the server should start, albeit with a few warnings about missing files.
This is the easiest step of all, and possibly one that your kids are familiar with.
Launch Minecraft. Make sure the profile uses the same version as your server. Copy the IP address of your server to your clipboard and click Play.
Click Multiplayer, followed by Add Server. Give it a name you'll remember and paste the IP address into the Server Address. Click Done, followed by Join Server.
Note: if you want to toggle fullscreen mode, you can do this with F11. If you don't have F11 on your keyboard, go to Options > Video Settings and click Fullscreen to toggle it.
Congratulations! You just setup a Minecraft server in the cloud. Now you can send the IP address to friends and invite them to play!
One of the issues that this setup has is that your server will shut down as soon as you logout of your SSH session. You can run the Minecraft server and leave it running using the following command.
nohup sudo java -Xmx1G -Xms1G -jar minecraft_server.jar nogui > minecraft.log 2>&1 &
This will keep everything running in the background, even after you logout. It also spits out a process id you can use to stop the server.
kill -9 processId
If you lose this number, you can find the process id by running
ps aux | grep java. You can also
shutdown all Java processes with
sudo killall java.
If you have any tips or tricks for improving this tutorial, I'd love to hear about them in the comments.
When I first setup a Minecraft server on AWS earlier this year, I never bothered to shut it down. The result was it cost me around $15 the first month. From then on, I simply started it whenever my son asked me to, then shut it down when he went to bed.
Ben Garton has a good tutorial on how to setup a cron job to shutdown the instance at midnight. He also shows how to start the server using a Desktop shortcut on Windows. If you've done something similar for Mac/Linux, I'd love to hear about it. Allowing your kid to fire up their own Minecraft server on demand (and shutting it down automatically) seems to be the most economical way to run things.
Devoxx4Kids Denver Workshop Next Week
If you'd like to learn more about Minecraft, developing mods and setting up your own server, you should join us at the Devoxx4Kids Denver Meetup next week (Saturday, August 15th at 9:30am). We'll be tuning in live to Arun and Aditya Gupta's vJUG session on Getting Started with Minecraft Modding. In the second hour, I'll show how to setup your own server on AWS and configure it to have the mods we've developed while watching the vJUG session. Thanks to our venue sponsor Tuliva, you don't even need to bring a machine! They have computers available for the kids to use and a sweet location too. RSVP today!
Related: It seems you can also run a Minecraft server on Heroku using heroku-minecraft.