Dec 31, 2015
Installing a Minecraft server on AWS
Running your own Minecraft server in AWS is pretty straightforward, so here goes!
1) Create an EC2 instance
I've picked a t2.small instance (2 GB RAM) running the Amazon Linux AMI and costing $0.028 per hour at the time of writing. Anything smaller feels... small for a complex Java app, but you're welcome to try. Details and pricing for EC2 instances may be found here.
Only the security group needs to be tweaked: on top of SSH access, you also need to open a port for the server (default port is 25565). If you want to play with friends (which is kind of the point), allow access from anywhere.
Your inbound rules should look like this:
2) Install the Minecraft server
Once you ssh'ed into your instance, it's time to select a Minecraft version. Let's retrieve the list (conveniently hosted in S3) :
$ wget https://s3.amazonaws.com/Minecraft.Download/versions/versions.json
My customer (ok, my son) wants to run 1.8.9, so let's download and extract this version:
$ mkdir minecraft
$ cd minecraft
$ wget http://s3.amazonaws.com/Minecraft.Download/versions/1.8.9/minecraft_server.1.8.9.jar
3) Configure the Minecraft server
Start it once:
$ java -jar minecraft_server.1.8.9.jar
It will fail and complain about approving the user agreement (bleh). All you need to do is to edit the eula.txt file:
Feel free to edit the server.properties file to add your favorite settings.
4) Start the Minecraft server
The best way to start a long-running server without losing access to the console is to use screen. Here is a simple tutorial.
$ sudo yum install screen -y
$ screen java -jar minecraft_server.1.8.9.jar
Your server is running, congratulations. You should be able to connect to it using the Minecraft client.
In the console, you will see players joining and leaving the game, as well as their UUID, e.g.:
[17:08:11] [User Authenticator #1/INFO]: UUID of player _____Dante_____ is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
This UUID is useful to declare players as operators in ops.json:
$ cat ops.json
That's it. Don't forget to detach from your server before ending your SSH session, or it will be killed (hint: CTRL-A D). And don't forget to stop the instance when you're not playing, it will save you money :)
Have a nice game and happy New Year!