Minecraft continues to captivate players with its endless possibilities, whether you are a seasoned player or someone returning to the game after a hiatus. The thrill of launching a server to enjoy some block-building adventures with friends is hard to match. However, before diving into gameplay, one must navigate the initial challenge of setting up a server. While renting a server from an online provider is an option, the real fun lies in creating your own server using a single board computer (SBC) that you might already have at home. Let’s explore how to set up a Minecraft server on a Raspberry Pi, a popular choice for such projects due to its simplicity and efficiency.
How to set up a Minecraft server on a Raspberry Pi
Get up and running for the first night
To begin, ensure your Raspberry Pi is powered on and connected to your network, either via Ethernet or Wi-Fi. For this guide, we will use Raspberry Pi OS, although Ubuntu Server is another viable option for enhanced performance. Assuming your Raspberry Pi is configured with SSH access, you can manage the server from a terminal on another computer.
- Start by updating your Raspberry Pi with the following command:
sudo apt-get update && sudo apt-get upgrade
- Next, install OpenJDK, which is necessary for running the Minecraft Java Edition server. Use the command:
sudo apt-get install default-jre
Releases of OpenJDK in the default repositories for Raspberry Pi OS may lag behind Minecraft server versions. If you encounter a LinkageError, consider switching to Ubuntu or using an older version of the Minecraft server binary.
- Create a directory for your server files:
mkdir server && cd server
- Download the Minecraft server binary. You can choose from several options, including the official server, Spigot, or PaperMC. Download the official binaries using:
wget
- To accept the Minecraft EULA, run the server once to generate the EULA file:
java -Xmx1024M -Xms1024M -jar server.jar nogui
The server will prompt an error, indicating the need to accept the EULA. Edit the ‘eula.txt’ file created in your directory, changing eula=false to true.
- Restart the server using the same command as before:
java -Xmx1024M -Xms1024M -jar server.jar nogui
- Your server is now operational. Watch as your world data generates, and look for the line indicating the server is running on the default port:
Starting Minecraft server on *:25565
You can stop your server with CTRL+C.
Editing your server properties
To customize your server, locate the server.properties file created in your directory. This file contains configurations for the official server binary. If you opt for an alternative server like Spigot or PaperMC, they will have their own configuration files. Make your desired changes and restart the server to apply them.
Running your server in the background
Once your server is running, you may notice it stops when the terminal closes. To resolve this, use a tool called screen to maintain a terminal session in the background, allowing you to detach and reattach as needed. If screen is not installed, you can do so with:
sudo apt-get install screen
To start a new screen session, first terminate your existing server process, then initiate a new session with:
screen -S minecraft_server
Name your session appropriately, especially if you plan to run multiple servers. After starting your Minecraft server, press CTRL+A followed by D to detach the session, leaving it running in the background.
Optimizing for performance
Optimizing your Minecraft server is essential, particularly for SBCs. Begin by disabling the GUI on your Raspberry Pi to free up memory. This can be done easily through raspi-config. Additionally, allocate more memory to your server. The Java Runtime Environment (JRE) provides options for memory management that are crucial. Here are two key flags:
- -Xmx – This flag sets the maximum heap size for the server, indicating the maximum memory the server can utilize.
- -Xms – This sets the initial heap size for the server, which should be equal to or less than -Xmx.
For a Raspberry Pi with 4GB of memory, configuring both flags to 2.5GB can yield satisfactory performance.
Using alternative binaries
If you intend to run a more extensive server or encounter performance limitations, consider using alternative binaries. For casual play, the official Microsoft binaries are straightforward and well-documented. However, for those seeking advanced performance tuning, Spigot and PaperMC offer extensive customization options. A comprehensive comparison of popular servers can be found on the Spigot wiki.
Port forwarding
To allow external access to your server, you may need to set up port forwarding, which exposes a specific application port, such as 25565, to the internet. This process requires access to your router’s administrator panel. For secure external access, consider setting up a WireGuard VPN instead, especially if you are only playing with trusted individuals.
A Raspberry Pi makes a great Minecraft server host
For those not aiming to host large-scale games, a Raspberry Pi serves as an excellent Minecraft server host. Its low power consumption, adequate memory, gigabit Ethernet, and affordability make it an ideal choice for learning and customizing your server without relying on third-party services.