Sign in

Self-hosting a Minecraft server in 2021

Step 1: Setup

Step 2: Installing Java

apt update && apt upgrade
apt install openjdk-11-jre-headless

Step 3: Create user

groupadd -r minecraft
mkdir -p /var/minecraft/server
useradd -r -g minecraft -d "/var/minecraft" -s "/bin/bash" minecraft

Step 4: Installing PaperMC

cd /var/minecraft/server
wget -O paper.jar https://papermc.io/api/v1/paper/1.16.3/latest/download
# let the minecraft user access the files
chown minecraft:minecraft -R /var/minecraft
su minecraft
cd /var/minecraft/server
java -jar paper.jar
enable-rcon=true
rcon.password=yourRconPassword
#You don't have to change it, but I would recommend setting the view distance to a value between 6 and 8 for better performance
view-distance=8

Step 5: Setting up mcrcon

cd /var/minecraft
wget -O mcrcon.tar.gz https://github.com/Tiiffi/mcrcon/releases/download/v0.7.1/mcrcon-0.7.1-linux-x86-64.tar.gz
tar xvzf mcrcon.tar.gz
mv mcrcon-0.7.1-linux-x86-64/mcrcon ./
chmod +x ./mcrcon
/var/minecraft/mcrcon -v
chown minecraft:minecraft -R /var/minecraft/

Step 6: Auto-restarting with systemd

cp minecraft.service /etc/systemd/system
systemctl daemon-reload
systemctl start minecraft.service
systemctl enable minecraft.service
journalctl -u minecraft.service -f

Step 7: Setup a firewall

apt install ufw
ufw allow ssh
ufw allow (The port of your server)
ufw enable
ufw status

Conclusion

Addendum

Hi, I'm Malte. I'm currently studying Media Computer Science.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store