Run your own Minecraft server on a VPS
Install a Paper server for Minecraft Java on Ubuntu 24.04, make it start by itself and open the port for your friends.
If you would rather skip the setup, there are ready-made game servers with a control panel. This guide is for running everything yourself. For a few friends, 4 GB of memory is enough, so a Cloud 4. The commands are for Ubuntu 24.04 and run as root.
1. Install Java
apt update && apt install -y openjdk-21-jre-headless
2. Add a user and download Paper
Paper is a faster version of the standard server. Copy the link to the latest build from papermc.io and paste it in place of THE-LINK.
adduser --system --group --home /opt/minecraft minecraft
cd /opt/minecraft
curl -o paper.jar THE-LINK
echo 'eula=true' > eula.txt
chown -R minecraft:minecraft /opt/minecraft
With eula=true you accept the Minecraft EULA.
3. Make the server start by itself
-Xmx3G gives the server 3 GB of memory. Leave about 1 GB for the system.
cat > /etc/systemd/system/minecraft.service <<EOF
[Unit]
Description=Minecraft
After=network-online.target
[Service]
User=minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java -Xms1G -Xmx3G -jar paper.jar --nogui
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now minecraft
4. Open the port
ufw allow 25565/tcp
Only needed if the firewall is on. Your friends join with the server's IP address under Multiplayer in Minecraft.
Console and log
journalctl -u minecraft -f
Change settings such as the name, difficulty and whitelist in /opt/minecraft/server.properties. Restart with systemctl restart minecraft.