I recently purchased a RPi4 8GB model and have been running PaperMC 1.16.4. I am running the beta 64bit version of RaspiOS. 1.16 is very CPU hungry and even pushes the RPi4. These instructions will eventually change to use PaperMC instead of Spigot.
For those interested, I allocate as much ram as possible and use the Aikar flags for starting the server. I also use Worldborder to pregenerate chunks. Full instructions will be added in the future as I test it further. But lets face it, Minecraft server is slowly leaving Raspberry Pi in the dust and I could see a day where it will not even start at all.
So I will leave version 1.12.2 as the default version for now, but give 1.16.4 on Raspberry Pi4 a whirl and tell me how it went for you. Your feedback on any helpful tweaks is appreciated and will be shared here.
How to Play Minecraft Java Mods on Windows
Building a full Linux vanilla server? See the Linux server install documentation.
Building a full Linux modded server? See the Modded Linux server install documentation.
Minecraft Server Version: 1.12.2
Oracle Java Version: 8u261
Approximate time to complete: 1 to 1.5 hours (including build time).
Step 1 - Download Java
Step 2 - Configure Java
Step 3 - Setup Your Environment
Step 4 - Install Minecraft
Step 5 - Configure your new Spigot Minecraft Server
Step 6 - Optional-- Configure Minecraft to start on bootup
Step 7 - Connect to Your Server
Step 8 - Hardening Your Minecraft Server if Visible on the Internet
Step 9 - Backup Your Server Frequently
Step 10 - Upgrading Your Minecraft Server
Step 11 - Recovering a Corrupted World
Step 12 - Creating Automatic Backups
Donate Your donations keep this site ad free -- Thank You
Get a $100 60 day credit towards a dedicated server with DigitalOcean by using this link.
Report errors in this guide. Your feedback is appreciated.
I recommend using a Raspberry Pi Model 3 or 3B which has one GigaByte of RAM and a quad core ARM cpu. Earlier versions, like the Pi A and B or even the low power PiZero are just too lightweight and will result in frustration. I am sure somebody somewhere has tweaked these versions to run a minecraft server well enough, but this build assumes a RaspberryPi 3 running Raspbian Stretch. If you have a model 2 it will likely work, but not as well as the 3.
Raspbian can be downloaded at https://www.raspberrypi.org/downloads/raspbian/
I prefer the Raspbian Stretch Lite image, but the full version of Raspbian Stretch with Desktop or installing via NOOBS should be fine. There are many tutorials out there so I will not recreate that here.
A Raspberry Pi is a good solution for a small minecraft server. Use the Raspberry Pi for light basic vanilla survival or creative world needs. If your focus is a small lan server for family and friends then this will work for you and is fully workable for less than five people. Use it to learn about managing minecraft servers. These skills are directly portable to setting up a bigger server on dedicated Linux hardware with Intel/AMD processors. Raspbian is based on Debian so the instructions would work on all Debian based servers like Ubuntu for example, with minor differences.
However, if you are into mods, redstone, highly complex automated farms and want to play with more than five people at once then this is not the solution for you. In those cases you need a beefier system with a better CPU and more RAM. A rented server with one of the many hosting companies available may give you what you need, including an enterprise level network connection that has a Service Level Agreement behind it. At home you most likely have an inferior residential service that is less suitable for network play. If your needs are this great then a Raspberry Pi will only lead to frustration for you.
Minecraft Server requires Oracle Java to run. You can install it on Raspbian with apt-get but that will give you an older version. Instead, get the latest available directly from Oracle.
a) Login to your pi via ssh
via Linux: ssh pi@address of your pi via Windows: Connect using a SSH client such as Putty
b) Download the latest version of Java (32bit) for ARM and copy it to the /opt folder on your pi.
Latest Version of Java
***NEW*** Oracle has changed the way they distribute their software. They have made things more difficult and now you need to login. There have also been changes to the license.
You will have to create a user login if you want to download the following file. jdk-8u261-linux-arm32-vfp-hflt.tar.gz
Once downloaded copy it to your /opt folder and then unpack it;
tar -zxvf jdk-8u261-linux-arm32-vfp-hflt.tar.gz
a) The next step will be to setup the Java environment so that your system recognizes how to access both the java binary and java compiler which will be required when building your minecraft server.
sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_261/bin/java 1 sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_261/bin/javac 1b) Set this version of java (and the compiler) as your default versions. These commands will give you a list of versions to select, just select the right version option. If this is the only version on your pi then it will tell you so and select that one automatically. Do the same for the java compiler (javac).
sudo update-alternatives --config java sudo update-alternatives --config javacc) Finally, check your version to make sure you are using the right one
java -version You should see the following; java version "1.8.0_261" Java(TM) SE Runtime Environment (build 1.8.0_261-b13) Java HotSpot(TM) Client VM (build 25.261-b13, mixed mode) javac -version You should see the following; javac 1.8.0_261
a) remove the link
sudo update-alternatives --remove "java" "/opt/jdk1.8.0_121/bin/java" sudo update-alternatives --remove "javac" "/opt/jdk1.8.0_121/bin/javac"b) remove the folder (be careful whenever using rm -r -f, a misplaced "/" or "*" could/will mess up your system)
cd /opt sudo rm -r -f jdk1.8.0_121
sudo apt-get update && sudo apt-get -y upgradeb) Install git
sudo apt-get install gitc) Install screen (This will be needed to run your minecraft server console while logged out of the pi).
sudo apt-get install screen
a) create the folder
cd /home/pi mkdir minecraft cd minecraftb) download the buildtools
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jarc) build the server
sudo java -jar BuildTools.jar --rev 1.12.2This would be a good time to get yourself a beverage. The size of the compiled jar file has jumped from about 22MB in version 1.11.x to 41MB under version 1.12.x. As a result it now takes about 50 minutes to build on a Pi3 and almost an hour and half on a Pi2.
Update: May 9 2018 Not sure what changed but building on a Pi3 only took 10 minutes today. I do not have a Pi2 anymore so I cannot comment on that version.
Be patient and come back in a bit. If all goes well you will have a file called spigot-1.12.2.jar (or whatever the latest version is at the time) in your minecraft folder.
If you have access to a faster Linux system you can always compile it on that system and copy the jar file to the raspberry pi, thus saving yourself quite a bit of time.
If you are still having problems, another alternative is to download this spigot jar file that I compiled on my own system. It is always best for security reasons to compile your own, but this file is provided with a GPG signature and its SHA256 hash which you can verify on your own system before using.
sudo java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-1.12.2.jar nogui*Note: Make sure to enter the right version that you have built. At the time of this writing Minecraft 1.12.2 was the latest version
b) accept the EULA. The first time you try to run your minecraft server you will be required to accept the EULA.
sudo nano eula.txtc) Change the following line to true and save the file
eula=trued) Run the server a second time to generate your world. World generation will take a while the first time. Subsequent server starts will be much quicker.
sudo nano server.properties change the following line with your preferred seed directly after the = sign level-seed= If you leave it blank Minecraft will generate a random world on first launchOn a Pi2 I changed the line view-distance to 4. You can tweak this up a little to 6 or 8 but if you find yourself getting some lag bring it back down a little. On a Pi3 I run it at 8 but have went as high as 10. If you get some lag bring it down a little.
sudo java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-1.12.2.jar noguie) Stop your server and install the NoSpawnChunks plugin. To stop your server, in the minecraft console type 'stop' and hit enter.
cd /home/pi/minecraft mkdir plugins cd plugins <-- Insert the file you downloaded heref) make things a little easier on yourself by using a script to start minecraft
mkdir /home/pi/startup cd /home/pi/startup nano minecraft.shg) Copy and paste the following in your minecraft.sh file
#!/bin/bash cd /home/pi/minecraft/ && java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-1.12.2.jar noguih) Save the file and make it executable
chmod +x minecraft.shi) Start your server
screen <---hit enter at the informational message sudo /home/pi/startup/minecraft.sh To exit the screen session hit 'CTRL AD'
sudo nano /etc/rc.localRight before the last line 'exit 0' add the following command, save and exit the file. This will allow the minecraft server to start in a detached screen session when the Pi boots up.
screen -dm -S minecraft /home/pi/startup/minecraft.shb) To access your console after bootup use the following command;
sudo screen -r minecraft To exit the screen session use the following command CTRL AD
b) Click the Add Server button
c) Edit the Server Info as follows (insert the IP address of your Raspberry Pi)
d) Enter your world for the first time and have fun!!!
If your Pi is connected directly to the internet with a public IP address then you need to setup your own firewall. Check out my documentation for setting up The Linux Five Minute Firewall. This method works great on Raspbian.
Activate whitelisting. It is extremely important to activate whitelisting if your server is visible on the internet. Port 25565
is a popular port and is actively scanned by all kinds of people using automated scripts.
They are looking for open servers so they can login and cause havoc on your world. Whitelisting will stop
unauthorized users from joining your world.
In your server.properties set the following value to true;
white-list=true Restart your minecraft server and run the following command at the console for each user you would like to allow. whitelist add minecraft_user1 whitelist add minecraft_user2 To remove a user whitelist remove minecraft_user2When an unauthorized user tries to connect to your server they will simply get a message that they are not whitelisted and will be turned away.
login to your pi cd ~ tar -zcvf minecraft_backup.tar.gz minecraft copy the minecraft_backup.tar.gz to a safe location, preferably another computer. This file can be used to restore your world if needed. Get into the habit of doing this regularly. You can even use the cron scheduler to automate the process at a specified time each day as explained in Step 12.
a) First thing you need to do is backup your world. Just like in Step 9 we will do the following;
login to your pi and stop your minecraft server. In the minecraft console type 'stop' and hit enter. cd ~ tar -zcvf minecraft_backup_version1.12.1.tar.gz minecraftb) download the latest buildtools
cd /home/pi/minecraft wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar -O BuildTools.jarc) build the new server. This will take a while, but if all goes well you should see a new spigot jar file.
sudo java -jar BuildTools.jar --rev 1.12.2Compiling your own is better, but I do make jar files that I have compiled available if needed. Files are signed with my gpg key and have a SHA256 hash that you can use to verify the integrity of the file.
jar file download
d) Update your minecraft.sh startup script to use the latest jar file
cd /home/pi/startup nano minecraft.sh Update the command to start the new jar file cd /home/pi/minecraft/ && java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-1.12.2.jar nogui Save the filee) Restart your server by either running your startup script with sudo or reboot your pi if you configured it to start on boot.
If you did your backups like we discussed in Step 9 then you are laughing. To restore your previous backup do the following;
Delete your existing minecraft folder cd ~ sudo rm -r -f minecraft copy your previously saved minecraft.tar.gz file to your /home/pi folder. restore your world tar -zxvf minecraft.tar.gzThat's it, restart your server and you have successfully restored from your last good backup. Any changes you made since that backup are gone, so it is important to do your backups regularly.
1) Provide a ready to use script to initiate the backup
2) Configure the cron scheduler to start the backup at 2:02am everyday
3) Name the backup day_of_week-minecraft-.tar.gz
This will create a 7 day rotation of backups with the oldest being overwritten with a new one.
a) Create a place for your script.
cd ~ mkdir scripts cd scripts nano mcbackup.shb) copy and paste this script into your mcbackup.sh file you have open in the nano editor. Change the dest= line to point to the folder you want your backups to reside in.
#!/bin/sh #################################### # # Backup minecraft world to a # specified folder. # #################################### # What to backup. Name of minecraft folder backup_files="minecraft" # Where to backup to. I backup to an external hd connected # to my Pi. enter the folder name where you want your backups to go. # Just make sure you have enough space to hold 7 days of backups. This # can be on the pi itself, to an external hard drive or mounted network share. dest="/media/nas/.minecraftbackups" # Create backup archive filename. day=$(date +%A) archive_file="$day-$backup_files-.tar.gz" # Backup the files using tar. cd /home/pi && tar zcvf $dest/$archive_file $backup_files
c) Save the file by pressing CTRL-X and entering Y
d) Make the file executable
chmod +x mcbackup.she) Test your script. Before creating the scheduled task ensure your script works
/home/pi/scripts/mcbackup.shYou should see the backup happening. Once completed open the file it created which should be in the location that you specified. Once you have confirmed that your backup works, create a scheduled task to automate the backups.
f) Create a scheduled task with the cron scheduler
crontab -eEnter this line at the end of your crontab and then save it.
02 2 * * * /home/pi/scripts/mcbackup.sh &> /dev/nullThis will create your backup every day at 2:02 am. That's it, in your folder where you specified your backups to be created you will have the following after one week;
Monday-minecraft-.tar.gz Tuesday-minecraft-.tar.gz Wednesday-minecraft-.tar.gz Thursday-minecraft-.tar.gz Friday-minecraft.tar.gz Saturday-minecraft-.tar.gz Sunday-minecraft-.tar.gzEvery day your oldest file will be replaced with the new backup giving you 7 days of backups.
That's it! Now have fun! I hope these instructions were helpful and that you learned a bit of how a Minecraft server functions.