minecraft installation raspberry pi

How to set up a Minecraft server on Raspberry Pi?

I have a lot of experience with Minecraft, whether as a player or as a server owner.
So naturally, I wanted to test it on my Raspberry Pi
I will share here the steps to follow to set up a multi-player Minecraft server at your place

How to set up a Minecraft server on Raspberry Pi?
To install a Minecraft Server on Raspberry Pi, follow these steps:

  • Install Raspbian
  • Download and install Spigot
  • Configure your server
  • Download and install plugins from Spigot
  • Start your server with the command: java -jar spigot-xx.jar

We will now see how to do this in detail, starting with a bit of theory on Minecraft, which will help you understand more
As usual, depending on your level, do not hesitate to use the table of content to pass paragraphs that are obvious to you

Minecraft introduction

What is Minecraft?

Minecraft is a sandbox game created by Mojang
This game has no goal. Each player will progress in the game in his way

At the launch of a game, the player appears in a world composed of blocks, representing the real world in a cubic form
The player will find different biomes (meadow, beach, mountains) and various blocks such as stone, trees, water, etc …

play minecraft

The player must then reap resources to improve his stuff (tools, weapons, armor)
It will also survive the monsters that appear at night and in caves

It’s an ideal game for kids, very educational and not violent
It is possible to play alone or with others players
And the purpose of this article is to show you how to set up a multiplayer game, with your family or friends

Minecraft client

To play a multiplayer game, you will need two things:

  • A client
  • A server

The client is the easy part
You can find it on the official website of Minecraft, whatever your operating system
It allows you to launch the game, create a solo game or join a server

minecraft launcher

The first time it will probably go through the options menu, to configure the control keys, audio and graphics settings

Minecraft server

Mojang also provides a server for his game, but I don’t recommend it
Indeed the server provided is minimal.
It will allow you to play multi-player on the same map, but will not let you to do any modification of the game

There are other providers of Minecraft servers, which offer the possibility to change it, thanks to plugins, we’ll see that later
In this article, we will choose the Spigot server, which allows this

Install Raspbian

First of all, you will need to install an operating system on your Raspberry Pi

Why Raspbian?

I advise you to install Raspbian which will allow compatibility with all the software that we will use

The Lite version of Raspbian is sufficient if you are going to use your Raspberry Pi only as a Minecraft server (otherwise it will depend on other uses)
The advantage of the Lite version is that it will leave more power and disk space for Minecraft, instead of using it for applications we will not use

For more advanced users, more scalable distributions, such as Arch Linux or Gentoo, may also be of interest

How to install Raspbian?

I will not explain the detailed installation of a Raspbian here
I advise you to read this article which will explain in detail how to do step by step

Once the tutorial finished, you must have:

  • Raspbian installed and updated
  • Network and Internet access working properly
  • Access to your Raspberry Pi via SSH from your computer

I recommend you to continue following this post from your computer, connected to your Raspberry Pi via SSH
So you can copy/paste command and work in better conditions 🙂

Install Spigot

As I said before, we’ll use Spigot for our Minecraft server
It’s free, with a large community and a lot of plugins you can add after the installation

Download Spigot

The first thing to do is to download Spigot
Spigot is not a ready to use package. You have to download it from the official site and build it

BuildTools.jar is a solution to build Bukkit, CraftBukkit, Spigot, and the Spigot-API.
We need to download it to build Spigot

Use these commands to get the required file in a new temporary folder:

mkdir /home/pi/spigot
cd /home/pi/spigot
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar

Then you are ready to start the next step

Build Spigot

Now that we have downloaded the jar, we need to launch the build of the latest version of spigot

  • Get back to your build folder if required
    cd /home/pi/spigot
  • Install prerequisites (Git and Java)
    sudo apt-get install git openjdk-8-jre-headless
  • Configure git
    git config --global --unset core.autocrlf
  • Run Buildtools
    java -jar BuildTools.jar

    It will take a little while (between 30min and 1hour)
    Be aware that you can add the –rev option to build a specific version of Spigot (ex: –rev 1.12.2)

    At the end of the process, you should get a success message like this
    spigot compilation buildtools

  • Check that spigot is ready in the build folder
    ls -latr /home/pi/spigot/*.jar

    In my case, the file I will use later is “/home/pi/spigot/spigot-1.12.2.jar”

Now that Spigot is ready, we can move to the next step

Minecraft server folder

It is not mandatory but I advise you to create a folder dedicated to your Minecraft server
This allows you to group everything in the same folder, to know the files concerned and to simplify the backups for example

Type the following commands to create a folder and move our Spigot file inside

mkdir /home/pi/minecraft
mkdir /home/pi/minecraft/server
cp /home/pi/spigot/spigot-1.12.2.jar /home/pi/minecraft/server

Don’t forget to change the spigot filename if you build another

First start

Now we can move to the server folder and start Spigot for the first time

cd /home/pi/minecraft/server/
java -jar spigot-1.12.2.jar

This start will fail, it’s normal
It will display something like this:

start spigot eula error

You have to first agree to the Minecraft EULA before running your server
Your first start just created a file named “eula.txt” in the server folder
Edit this file and set it to true

nano eula.txt

Replace “false” with “true”

Then start your server one more time
The server will create the basic needs:

  • Folders tree
  • First worlds generation (overworld, nether, and the_end)
  • Configuration files

This will take a few minutes
When the server console display “Done” you can stop it with this command:

stop

CTRL+C is also working but use “stop” if it works

stop spigot server

Technically, our server is already working
But first, we’ll have a look at the available configuration before moving on to play Minecraft

Configure Spigot

Spigot allows a lot of configuration, to create the server that suits you
We will see in detail what it is in each configuration file and what it can serve

Know first of all that most of the configuration files (from Spigot or its plugins) are in YML format
This format is easy to read, but it is important to respect the syntax
Thus tabs must be replaced by spaces, and characters such as single quotes often generate errors

Server.properties

The first file that can help you to configure the server is server.properties
This file comes from the original server from Mojang, Spigot keep it for more compatibility

Open the file to see what’s in it:

nano server.properties

As you can see, the file is easy to read: one parameter = one value

Now I will explain the most important options from this file, that you’ll probably use

  • server-port: By default, the Spigot server can be accessed to the port 25565, but you can change it with this parameter
  • level-seed: Each world is generated from a seed, if you want a specific world, you can enter a seed here, delete the world folder and restart the server to get this exact world. There is a lot of website giving you examples of seed. MinecraftSeedHQ is one of them
  • hardcore: Do you want to make the game more complicated? The hardcore mode will ban the players at their first death 🙂
  • pvp: (Players vs Players) You can disable this option to avoid pvp on your server
  • difficulty: By default, the server will be in EASY mode. You can increase this value to make it more difficult (values between 0 and 3)
  • gamemode: By default, the server will be in Survival mode. You can change this value to play in another game mode (0=Survival, 1=Creative, 2=Adventure, 3=Spectator)
  • spawn-monsters: You can disable this if you want to play without monsters
  • motd: It’s the name of the server that will display in your server list. You can change it to know that it’s your Raspberry Pi server 🙂

You can find all the other options in the Minecraft wiki but most of the time you’ll not need others

Spigot.yml

Spigot.yml is the first configuration file added by Spigot to customize your Minecraft server
It will allow you to change game settings and server settings
For example, you can change in this file the hoppers speed or the log file behavior

Most of the time for a home server, you will not need this kind of options
You could probably spend a little time in this file to improve the performance for your Raspberry Pi, but it’s not mandatory
If you want more information about this file, you can find it in the Spigot wiki

Bukkit.yml

Spigot is based on Bukkit
Bukkit was a similar project, to extend the multi-player Minecraft server
Spigot decided to keep the bukkit.yml file that contained all the options for Bukkit servers

This file contains pretty much the same kind of options as spigot.yml
It is also often complicated to know in which file we will find which option

In the same way, as for the Spigot.yml file, it is unlikely that you need to go to edit bukkit.yml
However, if you want to know more, help is available on their wiki

Offline mode

I would now like to write for a few moments on the online-mode option that you may have seen in the server.properties file

Remember that Minecraft is a paid game, which can be bought on the official website
But there are “crack” versions, with launchers that allow you to play solo, or join cracks servers without ever logging into a Mojang account

The online-mode parameter is used for this
If you set it to false, crack launchers will be able to connect to your server
I do not necessarily encourage you to do this, but as part of a closed server available only at home to play with your family, this seems like a good option
Shiginima is a good launcher to use with this option

Connect to the server

Take your time to finish the server configuration and we can continue to test the server access

Don’t forget to restart the Spigot server with your new configuration files:

java -jar spigot-1.12.2.jar

Get the game launcher

For a paid version, you have to download the launcher from the official website
Log in to your account, and click the Download link

download minecraft launcher

If you want to try the game with a cracked launcher, you can download Shiginima from the link below, or any other launcher from your choice

Then follow instructions to install it

Start the launcher

Official launcher

If you are using the official launcher, it will ask you to log in on the first start

login minecraft launcher

Enter your credentials and submit the form

Then you will get the Play button

play minecraft

But before clicking the play button, you need to check that the game will start with the same version as your server
Most of the time when a new Minecraft version is available, the server developers will need some days/weeks to update the server, so there is often a gap between the two versions

In my case, the server is in 1.12.2, but the launcher start in 1.13.1
So to change this:

  • Go to “Launch options” in the menu
  • Click on “Add new”
    minecraft launch options
  • Enter a friendly name (ex: 1.12.2)
  • Choose the same version as your server
  • Save

If you come back to the launcher home, you will see that the Play button changed and you can now select which version you want to use

choose minecraft version

Shiginima launcher

The Shiginima launcher uses the method of the old official launcher, so it’s a little different

The first thing to do is to choose the name you want to use.
There is no account needed

shiginima launcher

Then press Play and access to the launcher interface

Then you have to check that the game version display in the bottom right is the same as your server
In my case, the server is in 1.12.2, and the launcher start in 1.13.1
So, you can change it following these steps:

  • Click on the Edit Profile button in the bottom left
  • In the Use version dropdown list, choose the correct game version (ex: 1.12.2)
  • Click on Save Profile

The game version at the bottom right should have changed
You can now click “Play” to start the game

Add the server

Whatever the chosen launcher you should now find yourself on a screen like this

minecraft launcher 1.12

If you have not done it yet, take a look at the game’s options to adjust controls, audio and graphics options to suit your needs.

Then we’ll add our server and connect to it:

  • Click on the Multiplayer button
  • Click on the Add server button
  • Enter a server name (whatever)
  • Enter your Raspberry Pi IP address
    • If you change the default port, you have to put it in this field following the format [IP]:[PORT], for example, 192.168.1.200:12345
      connect minecraft server
  • Click on the Done button

Your server should now display in the server list like this

minecraft server list

Double click on it to connect to your server!

If you check the server console, you’ll see your player name logged in

minecraft player login

We now have a basic functional server
You can already play with your family or friends

But we chose Spigot to be able to add plugins, not to get a simple server
So that’s what we’re going to see now

Plugins

Plugins introduction

As I said before, plugins can improve or change the behavior of Spigot

I will give you some examples of features that plugins can bring.
It will be clearer

  • Add commands, for example, the ability to return to the server spawn with /spawn
  • Give you rewards based on what you do in the game
  • Add permissions, such as not being able to break another player’s house

There are thousands of plugins that are already full of things
And the possibilities are almost endless, develop a new plugin to add any functionality that you have in mind

Download plugins

Spigot lists most public plugins on its website, in the Resources category
You can search for a plugin through the Categories menu or with the search engine

For a family server, you do not have to add plugins.
If you trust the people who access the server, the basic version may be enough
But if you want more security or more features, do not hesitate to add a few

Here is a list of the main plugins found on the majority of multi-player servers:

  • Essentials: Essentials will add all the most useful commands to your server. For example, you can create checkpoints with /sethome and come back to this place with /home
  • PermissionsEx: PermissionsEx will add permissions to your server. Players will only be able to do what you have decided. You can create groups of players, like Admins with all access, and players with only the minimum permissions.
  • WorldGuard: WorldGuard will allow you to create protected regions in your world. For example, you can preserve the spawn of the server, to avoid its destruction by new players
  • WorldEdit: WorldEdit works well with WorldGuard, it allows you to make the selection of a region, and transformation of the world (copy/paste for example)
  • Multiverse: Multiverse-core is a plugin to manage multiple worlds in your servers. For example, you can have a resource world and a build world
  • Vault: Vault allow players to use money in the game
  • Lockette: Lockette is a simple plugin to protect chests or doors. If you put a private sign on your chest, nobody can open it except you

There are many others, which may be useful depending on what you want to do, but those are part of the essential plugins

Plugins are java files in a .jar format
To download one, go to the plugin page (ex: Multiverse), click Download and recover the .jar file

We’ll see next how to install them on your Spigot server

Install plugins

To add new plugins on Spigot, you have to put the .jar file in the plugins subfolder

Transfer it from your computer

If you have downloaded the plugin file on your computer, you have to transfer it via SSH to your Raspberry Pi:

  • On Mac/Linux: use scp or rsync command
    scp Multiverse-Core-2.5.jar pi@192.168.1.22:/home/pi/minecraft/server/plugins/

    Don’t forget to change the IP address of the Raspberry Pi

  • On Windows: use the WinSCP software
    • Create a new site with your Raspberry Pi settings
      winscp settings
    • Then click Save and Login
    • The right tab is the Raspberry Pi folder tree
      Go to /home/pi/Minecraft/server/plugins
    • Drag and drop the plugin from the left to the right
    • You should get something like this
      winscp files

Direct download

Another way to do this is to download the file directly to the Raspberry Pi
This way is not always possible, but when you have the plugin’s direct link you can use wget to download the file:

cd /home/pi/minecraft/server/plugins/
wget [LINK] -o [PLUGIN].jar

Apply changes

Whichever method you use, you must now restart the server to apply the changes

  • Return to the server console in your SSH client
  • Stop the server
    stop
  • Then restart the server
    java -jar spigot-1.12.2.jar

On the next start, the plugin will be installed and available in the game

Configure plugins

Most of the time, when you install a new plugin, a new folder will be created in the plugins folder
This folder contains the plugin configuration

├── Multiverse-Core
│   ├── config.yml
│   ├── scripts
│   │   └── scripts.bin
│   └── worlds.yml
├── Multiverse-Core-2.5.jar

If necessary, edit these files by referring to the documentation of each plugin

Go further

These tips are not mandatory to play Minecraft on your server
But it can help you to have a more stable server

Use screen

As you’ve probably noticed, the server you launch in your SSH console stops if you are disconnected from the Raspberry Pi or if your computer goes to sleep …

We have to start the Spigot server on the Raspberry Pi directly
For that, I recommend you to use screen

  • Install screen
    sudo apt-get install screen
  • Create a new screen for your Minecraft server
    screen -S minecraft
  • Start the server
    cd /home/pi/minecraft/server
    java -jar spigot-1.12.2.jar
  • Quit the screen with CTRL+A followed quickly by CTRL+D

This time even if you disconnect your SSH session the server will continue to run
To return to the screen, use the following command:

screen -r minecraft

Start server script

For now, we have started our server manually, but it is advisable to create a script for that

A simple script

Here is the most basic script you can create to start your Minecraft server

  • Go to your server directory
    cd /home/pi/minecraft/server
  • Use nano to create the script
    nano start.sh
  • Paste this lines
    #!/bin/bash
    java -jar spigot-1.12.2.jar
  • Save and exit (CTRL+O, Enter, CTRL+X)
  • Add the execution permission
    chmod +x start.sh
  • Start the server
    ./start.sh

As you maybe notice in the spigot.yml configuration file, if the server crashes, Spigot will look for a start.sh script to restart the server, so it’s important to call this script exactly like this

Options

Most of the time, we start servers with additional parameters
Java can take a lot of options, and Spigot too

You maybe noticed that in the server start, they recommend using another command, so we will edit out the script to add this options

#!/bin/bash 
java -Xmx1024M -Xms1024M -jar spigot-1.12.2.jar
  • -Xmx specifies the maximum size, in bytes, of the memory allocation pool
  • -Xms specifies the initial size, in bytes, of the memory allocation pool

Auto restart

The last thing we can add to this script is an auto restart
We saw that in case of a crash, Spigot would try to restart the server
But it does not always work, and if you stop the server yourself by mistake, you have to go and restart it.

For the server to restart automatically, modify your startup script so that it looks like this:

#/bin/bash
while true
do
java -Xmx1G -Xms1G -jar spigot-1.12.2.jar
echo Reboot
#You can add other commands to do at each reboot here
#(backup or log rotation for example)
sleep 5
done

Start on boot

Finally, if your Raspberry Pi is dedicated to your Minecraft server, you can launch it automatically at every boot

For that add the script in the crontab this way:

  • Edit the crontab
    crontab -e
  • Paste this line at the end
    @reboot /home/pi/minecraft/server/start.sh
  • Save and exit (CTRL + O, Enter, CTRL + X)

Backups

If you spend a lot of time playing, setting up a backup at least once a day can be a good idea

For minimum security, you can install a backup plugin like this
This plugin will create backups at defined intervals and allow you to restore them easily

For a more valuable server, it will probably be necessary to put in place a more advanced strategy
For example, you can create a compressed archive of the server folder, keeping a few days of archives

Access from Internet

As you have seen your Minecraft server is accessible via an IP and a port
It is therefore quite possible to open this port on the Internet, adding a NAT rule on your internet box

This firewall rule will allow you to invite friends to play on your server
But in this case think about the security of your server, adding the plugins recommended above, because anyone can come on your server 🙂

Conclusion

You now know how to set up an advanced Minecraft server on a Raspberry Pi at home

Minecraft is an infinite universe, whether in the game or its community, its plugins, its improvements possibilities
If you didn’t know it you shouldn’t be disappointed, and if you have already played solo, the discovery of the multiplayer mode should revolutionize your games 🙂

 

 

 

 

 

 

Leave a Comment