Matt RaibleMatt Raible is a Web Architecture Consultant specializing in open source frameworks.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: AngularJS, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Setting up a Minecraft Server in the Cloud

Minecraft 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

  1. 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.
  2. Click on EC2 in the top left corner, then Launch Instance on the following screen.

    AWS Console

  3. Select Amazon Linux.

    Select Amazon Linux

  4. Choose an Instance Type of t2.micro, then click Next: Configure Instance Details.

    Instance Type

  5. 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.
  6. On the Tag Instance screen, assign a name to your server. I chose "Minecraft Server". Click Next: Configure Security Group to continue.

    Tag Instance

  7. 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.

    Security Group Configuration

  8. You'll be warned about allowing any IP address on the following screen. Click Launch to continue.

    Review Instance

  9. You'll be prompted to create a new keypair. I chose "minecraft" for my key pair name. Click Download to download your key pair.

    Create 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.

    Launch Status

  10. 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.

    Public IP Address

    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.

    SSH

Step 2: Install a Minecraft Server

  1. 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.

  2. 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
    
  3. 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 Warning

  4. Edit eula.txt by 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
  5. 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.

    Server launches successfully!

Step 3: Connect to Your Server and Play!

This is the easiest step of all, and possibly one that your kids are familiar with.

  1. 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.

    Minecraft Launcher

  2. 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.

Next Steps
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.

Posted in Java at Aug 05 2015, 03:03:00 PM MDT 8 Comments
Comments:

I actually tried setting up a Minecraft server on Digital Ocean...it worked well enough, but a big enough droplet instance to support as many users as I needed to support, using a customized server modpack, was at least $40 a month.

I wound up doing better with a dedicated Minecraft-hosting service, Bisect Hosting. I pay about $20 a month for a server which can support 60 users (far more than we need), and it fully supports customized server modpacks.

For future exploration, you might look at Minecraft mods and modpacks. Mods are, like Minecraft itself, written in Java, and there's a fairly-standard API (Minecraft Forge) that most of them use. We use a customized modpack that I created (easy enough to do with the Technic Launcher system), with about 60 mods. They extend the game in various nifty ways. If you've ever wanted to have a nuclear reactor in Minecraft, there are mods that let you do that...

Posted by Erbo on August 05, 2015 at 03:30 PM MDT #

[Trackback] Last weekend, Denver's Devoxx4Kids gathered at Tuliva to learn about Modding Minecraft . Several kids (ages 7-15) were introduced to programming Java by the founder of Devoxx4Kids USA , Arun Gupta , and his son, Aditya . They use...

Posted by Raible Designs on August 19, 2015 at 08:54 AM MDT #

This totally helped!

Posted by Netizen on April 08, 2016 at 01:37 PM MDT #

I keep getting a Permission denied (publickey) on step 10. Any chance you have some pointers?

Posted by Matt on April 30, 2016 at 06:04 PM MDT #

Matt - did you run "chmod 400 .ssh/minecraft.pem" from step 9?

Posted by Matt Raible on May 02, 2016 at 08:30 AM MDT #

How much does the AWS hosting for this cost per month? If free, how many concurrent users can it handle before it begins to slow down? -- Furry cows moo and decompress.

Posted by Wyrd on June 28, 2016 at 04:47 PM MDT #

Wyrd - I only ended up running it for about a month before my kids lost interest. I think it was around $20. They never had more than a couple friends join, so I don't know how much load it can handle.

Posted by Matt Raible on June 28, 2016 at 06:31 PM MDT #

Latest minecraft server version can now be found at https://minecraft.net/en-us/download/server

Posted by Asaf Add on February 21, 2017 at 11:36 PM MST #

Post a Comment:
  • HTML Syntax: Allowed