Self-hosting a Minecraft server on Linux

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
# let the minecraft user access the files
chown minecraft:minecraft -R /var/minecraft
su minecraft
cd /var/minecraft/server
java -jar paper.jar
#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

Step 5: Setting up mcrcon

cd /var/minecraft
wget -O mcrcon.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





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
Malte Janßen

Malte Janßen

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