Using the Raspberry Pi as a Minecraft server

The Vanilla Server

The vanilla server needs a Java environment as a pre-condition. If an SSH connection exists, then you should enter java -version in the terminal to control the Java installation. The Raspberry Pi will then communicate the version number of the installed Java environment. Raspbian automatically installs Java as part of the standard installation. If, however, command not found appears, you should install Java via:

sudo apt-get install oracle-java8-jdk

For security reasons, you should create a single user for the server and a new directory, which you then designate the home directory for the user. From the home directory, you should download the server software file minecraft_server.<Version>.jar [9] from the Internet and adjust the file access rights (Listing 1). Be careful to download the most recent version, which will ensure that the server has the latest functionality. Older servers are not always compatible with a current Minecraft client.

Listing 1

Installing the Server

$ sudo adduser --system --no-create-home minecraft
$ sudo mkdir /opt/minecraft
$ sudo usermod -d /opt/minecraft minecraft
$ cd /opt/minecraft
$ sudo wget https://s3.amazonaws.com/Minecraft.Download\
  /versions/<Version>/minecraft_server.<Version>.jar
$ sudo chown minecraft:nogroup -R /opt/minecraft

Now the installation process is complete. Specifying a special user makes installation a bit more complex than many of the other installation instructions available over the Internet; however, on principle, server services should always run in the context of their own user because of security concerns.

Because a Java archive is involved, the server must be started via a Java command. The simplest way to do this is to change to the archive directory and invoke the program as shown in Listing 2. The screen session lets you close the terminal window after starting the service and detach from the session via Ctrl+A,D.

Listing 2

Starting the Server

$ screen -S minecraft
$ cd /opt/minecraft
$ sudo -H -u minecraft java -Xmx256M -Xms256M -jar minecraft_server.1.8.7.jar
### In case of problems, you should start the server \
  without any additional parameters.
$ sudo -H -u minecraft java -jar minecraft_server.1.8.7.jar

When the vanilla server starts for the first time, you will immediately get an error message about the lack of consent to the end user license agreement (EULA). Here, the software installs the text file eula.txt in the directory; enter

sudo nano eula.txt

to open the file in the standard Nano editor, and change the eula=false line to eula=true. Then, save the change with Ctrl+O and confirm the file name with Enter. You should then return to the terminal with Ctrl+X and reinvoke the Minecraft server. It will now indicate in the console that it is ready to operate (Figure 1).

Figure 1: You can follow what is happening on the Minecraft server from the console. For example, you can see the creation of game worlds and logins by users.

Cuberite

Cuberite servers are installed in a similar fashion. One advantage of these servers is that a compiled version exists for the ARM processor. Additionally, Cuberite offers a web interface for the configuration process. With the vanilla server, you need to edit configuration files or use commands to work on them from the Minecraft client.

To install Cuberite, download the current build for ARM processors [10], create your own user account for Cuberite, and unpack the program to the /opt/ directory (Listing 3). The files and folders that appear still have outdated project names, such as /opt/MCServer/.

Listing 3

Installing Cuberite

$ sudo adduser --system --no-create-home cuberite
$ sudo tar -xf Cuberite.tar.gz -C /opt
$ sudo usermod -d /opt/cuberite cuberite
$ sudo chown cuberite:nogroup -R /opt/MCServer

Next, you should invoke Cuberite inside of a Screen session and use the account installed previously (Listing 4). When it starts, the program will automatically install the settings file webadmin.ini for the web interface. The login data will be missing from this file because of security concerns. Thus, you should shut the server down from the terminal by pressing Ctrl+C and open the file in Nano:

Listing 4

Starting Cuberite

$ screen -S cuberite
$ cd /opt/MCServer
$ sudo -H -u cuberite /opt/MCServer/MCServer
$ sudo nano /opt/MCServer/webadmin.ini

Once the file is opened, delete the leading semicolon that appears in front of the user name and enter a password for the admin account (Listing 5). Pressing Ctrl+O and Enter saves the changes you have made. You can return to the terminal via Ctrl+X.

Listing 5

Setting Up the Admin Account

; This file controls the webadmin feature of MCServer
; Username format: [User:*username*]
; Password format: Password=*password*
; for example:
[User:admin]
Password=topsecret
[WebAdmin]
Ports=8080
Enabled=1

From the terminal, you should start Cuberite again. This time, you log into the web interface (Figure 2) with a browser by using the URL http://localhost:8080 or generally via http://<IP-Address>:8080. You also need to use the previously assigned user data. Most of the entries are self-explanatory. Typically, you will not have to change anything when you start out. (See the box "Compiling Cuberite" for more information.)

Compiling Cuberite

Cuberite can also be compiled directly from the source code and then optimized for the system it will run on. The project makes a script available on GitHub for doing this. The script performs most of the build automatically [14]. However, the build process takes several hours on a Raspberry Pi. We did not detect any improvement in performance at the conclusion of this type of build.

Figure 2: The web interface in Cuberite is especially helpful for beginners who are starting out for the first time with a Minecraft server.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Learning to program with Minecraft

    No two ways about it: For knowledge to stick, the training must be entertaining. Fortunately, learning to program in Python has just become a lot more fun – now you can learn by playing Minecraft.

  • Don't Use a Hammer

    When you first start building, you probably learn how to use one device and one programming language. Then comes the day you design a project that your toolset either can't solve or forces you to jump through too many hoops to get the outcome you desire. That's the day you start looking at new devices and languages to solve your problem. Having an arsenal of tools at your disposal makes solving problems easier.

  • In with the New

    I am new in the seat of editor-in-chief here at RPG, but I’ve been hanging around in the wings for some time now.

  • Event Report: Pi and More 3

    From all over Germany, Raspberry Pi fans went to Trier in mid-June for "Pi and More 3." For a whole day, visitors of all ages enjoyed lectures and participated in hands-on workshops.

  • Exploring the Kano Kit Pi pack and learning environment

    The Kano Kit learning platform puts the Pi in easy reach for even the youngest users.