Game Servers – Minecraft

Minecraft being one of the most popular games out there, surprisingly still being popular after a decade. In this tutorial we will be using Ubuntu 18.04 and we will hosting a server for Minecraft Java Edition. We will cover both hosting of the offline version and online version. We will also cover non-modded, modded Minecraft takes up a lot of ram which means you will most likely need to spend more money on hosting than non-modded.

Hosting – VPS

First, you need to find a host which sells Ubuntu Virtual Private Servers. This is often easy to find, but it’s difficult finding the one which the right balance of price and support / usability. For our tutorial, we will be assuming you will be using a host which already does the pre-setup for the user. We will also provide VPS services that we recommend.

Server Space

Pricing
Updated on 26/10/2020

We have used Server Space before, and had a great experience using them. Their prices are cheap and flexible. However, the support may not be as quick as other services. We also have no downtimes with their services and overall had a great experience with them.

Creating The Server

Server Space allows users to create servers within 2 click, follow along

Click on create then create server

After clicking on create, they offer a few options, however, we will stick to these options

Make sure to select the ubuntu 18.04 x64

After creating a server, they should redirect you to their control panel. This step if really up to you, but you can choose to either use PuTTY or use their own web console. i Would recommend using Putty, since its easier to copy and paste commands and overall it’s much faster.

Installing Packages & Firewall

Packages

Let’s start off with installing the bare-bone packages required for the tutorial. We will be using screen to use multi-terminals easily. Before anything, make sure to update your current packages

sudo apt update

Next, let us install screen. Screen basically allows us to detach from terminal sessions while leaving that session running. So we can create a session for our Minecraft server while still being able to use the terminal. This makes life much easier, as without screen, when you exit your terminal, the game server will go down with it. Install screen with the following command

sudo apt install screen

Once you have installed screen, make sure to type Y and ENTER, if it askes to install additional packages.

Now that we have screen installed, let us install the OpenJDK 8 JRE Headless, this is the non GUI version of Java which makes it ideal to install on a server. Install this by running the following command

sudo apt install openjdk-8-jre-headless

Firewall

Once you are done with all the packages, let us move onto the firewall. Do note that different hosting services has a different system. For the hosting service that we suggest above, this will work, however for things like Google Cloud Platform, this will not work, for providers like those, you have to go to their own firewall rule section and modify it.

As Minecraft uses port 25565 by default, we will need to allow traffic to flow through the port. We can add that rule by running the following command

sudo ufw allow 25565

Downloading The Files

This part is pretty easy and should be done fairly quick. If you like to host the latest version of the game – DO NOT do this if you want a modded world, try to find a stable version. You can find the latest version of the game on the Official Minecraft Website – older versions here. We can download the files using two different ways, first way is wget, second way is FTP. We will be using wget, however, if you are using Google Cloud Platform, they allow you to upload files using the console.

Find the link of the download, for the latest version – using the official website, we get

https://launcher.mojang.com/v1/objects/f02f4473dbf152c23d7d484952121db0b36698cb/server.jar

Alright, once we got the link to the version we like, let us create a folder for it. You can store your folder anywhere you like, however we will be placing it in the home folder. Run the following command

mkdir /home/minecraftserver

Now let us get into the folder

cd /home/minecraftserver/

Once in, we then download the minecraft server file by running the following wget command

wget https://launcher.mojang.com/v1/objects/f02f4473dbf152c23d7d484952121db0b36698cb/server.jar

Once its downloaded, you can change the name of the server file name if you like by using the following command

mv server.jar MinecraftServer.jar

Make sure that everything is installed properly, you can run the command ls to view the files in the directory you are in.

Configuration the Server

Now that you got all the files downloaded, lets move onto running the server. Let us just start the initial configuration for the server by just running it for the first time. It will ask you to accept the EULA and such, and will create the necessary files such as the configs and others. We run the server by using the following command

java -Xms512M -Xmx1024M -jar MinecraftServer.jar nogui

Before running the command, let us take a look at the most used parameters, just in-case you would like to change it for your server

  • Xms512M – This allows you to change your initial RAM usage for java. Increase this limit with you want your server to be able to start with more RAM. This parameter shouldn’t really be raised, however, if you know what you are doing, you can raise this to your needs. You can use Megabytes or Gigabytes by changing the last letter to M or G
  • Xmx1024M – This allows you to change the RAM limit of the server. For modded servers, you may need to change this limit to a much higher value – make sure to spare some RAM for your system and not use everything on the server. Leaving the system with 500MB should be fine. So if you have 6GB RAM on your server, you can use Xmx5500M to use 5.5GB RAM for your server.
  • Jar – Just points to the jar file we will be running. For the server, we will be pointing it to our Minecraft Server file
  • NoGUI – This just removes the GUI system. Since we are running the server using a terminal, there is no need for a GUI, therefore, we can use this parameter to remove it

When you run the server for the first time, you will get an error asking you to agree to their EULA in order to run the server, it will look something like this

[12:25:31] [22:05:31] [main/ERROR]: Failed to load properties from file: server.properties
[12:25:31] [main/WARN]: Failed to load eula.txt
[12:25:31] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

We can resolve this error by entering into the eula.txt using a editor of your choice – we will use nano

nano eula.txt

The file will look something like this

#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Tue Mar 24 12:35:31 UTC 2020
eula=false

Make sure to have a look at their EULA before agreeing to it, once you are done reading, change

eula=false

to

eula=true

Once you are done, press CONTROL+X, once it askes you if you would like to save the modified buffer, type Y then ENTER

And that’s it. You are almost there, once we are done modifying the EULA, we can then head onto the server.properties then modify it to your liking. Hop into the file by running the following command

nano server.properties

The file should look something like this

#Minecraft server properties
#Thu Apr 30 13:12:49 UTC 2020
spawn-protection=16
max-tick-time=60000
query.port=25565
generator-settings=
force-gamemode=false
allow-nether=true
enforce-whitelist=false
gamemode=survival
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=easy
spawn-monsters=true
broadcast-rcon-to-ops=true
op-permission-level=4
pvp=true
snooper-enabled=true
level-type=default
hardcore=false
enable-command-block=false
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
function-permission-level=2
rcon.port=25575
server-port=25565
server-ip=
spawn-npcs=true
allow-flight=false
level-name=world
view-distance=10
resource-pack=
spawn-animals=true
white-list=false
rcon.password=
generate-structures=true
online-mode=true
max-build-height=256
level-seed=
prevent-proxy-connections=false
use-native-transport=true
motd=A Minecraft Server
enable-rcon=false

Here are some of the things you should change to your liking before running the server. Make sure to not change the level name as it will change your whole world and create a new world if not found. You can also switch that name to a world you already have if you accidently changed it or want to upload your own world

  1. Spawn Protection – Determines the side length of the square spawn protection area as 2x+1. Setting this to 0 disables the spawn protection. A value of 1 protects a 3×3 square centered on the spawn point. 2 protects 5×5, 3 protects 7×7, etc. This option is not generated on the first server start and appears when the first player joins. If there are no ops set on the server, the spawn protection is disabled automatically as well.
  2. Force Gamemode – Force players to join in the default game mode.
    • false – Players join in the gamemode they left in.
    • true – Players always join in the default gamemode.
  3. Gamemode – Defines the mode gameplay. If a legacy gamemode number is specified, it is silently converted to a gamemode name.
    1. survival (0)
    2. creative (1)
    3. adventure (2)
    4. spectator (3)
  4. Online Mode – Server checks connecting players against Minecraft account database. Set this to false only if the player’s server is not connected to the Internet. Hackers with fake accounts can connect if this is set to false! If minecraft.net is down or inaccessible, no players can connect if this is set to true. Setting this variable to off purposely is called “cracking” a server, and servers that are present with online mode off are called “cracked” servers, allowing players with unlicensed copies of Minecraft to join.
    1. True – Enabled. The server assumes it has an Internet connection and checks every connecting player.
    2. False – Disabled. The server does not attempt to check connecting players.

Once you have set everything you need to, and changed the EULA to true. You can now start the server.

Running the Server

This will be the command you will use every time you would like to start the server

sudo screen -S minecraft java -Xms512M -Xmx1024M -jar MinecraftServer.jar nogui

Let me explain what exactly this is doing

  • Screen – Like i mentioned above, we will be using screens to launch a terminal which we can detach from and still leave the game server running in a different process
    • -S minecraft – This starts a new terminal session with the name minecraft. Make sure you use a name which is easily to memorize, as you might need to hop back into that session to check logs or shutting down the server

When you are ready to log out of your server, be sure to detach from the session with Ctrl + A + D and then log out.

You can then get back into the session running the Minecart server by running the following command

sudo screen -R minecraft

Once you are in, you can shut down the server by pressing Ctrl + C

That’s it! You got your very own server, you can now launch Minecraft, boot up the same Client version as your Server version and add the server to your list.

One thought on “Game Servers – Minecraft

Leave a Reply