A Minecraft game server
Running your own Minecraft Java Edition server gives you full control over the game version, the world, and the settings — unlike joining someone else's public server. In this article you'll install the right Java version on your mHost VPS, download and run the server jar (vanilla or Paper), accept the license agreement, configure the key settings, and keep the server running permanently — via systemd or tmux/screen — with a port opened for your friends.
What you'll need
- An mHost VPS on Ubuntu 22.04/24.04, Debian 11/12, or AlmaLinux/Rocky Linux 8/9.
- SSH access as
rootor a user withsudorights. - At least ~2 GB of free RAM for the Java process itself — a comfortable minimum for a small vanilla server. For Paper with plugins or a noticeable number of players, plan for more (see Step 5).
- A public IP address for the VPS — that's the address your friends will connect to; a separate domain isn't required.
Step 1. Install the right Java version
Each Minecraft version line has its own minimum required Java version — an older Java simply refuses to launch a newer server:
- versions 1.17–1.17.1 — Java 16;
- versions 1.18–1.20.4 — Java 17;
- versions 1.20.5–1.21.11 (the last version under the old
1.xnumbering) — Java 21; - versions 26.1 and newer (starting in 2026 the game switched to "year.drop" numbering, e.g.
26.1,26.2) — Java 25.
Option A: package from the distribution's repository
Works for Java 21 out of the box on Ubuntu 22.04/24.04 and AlmaLinux/Rocky Linux 9.
Ubuntu 22.04/24.04:
sudo apt update
sudo apt install -y openjdk-21-jre-headlessAlmaLinux/Rocky Linux 9:
sudo dnf install -y java-21-openjdk-headlessOption B: the Adoptium (Temurin) repository — for everything else
You'll need this on Debian 11/12 and AlmaLinux/Rocky Linux 8, where the native repositories don't even have Java 21, and also whenever you need Java 25 and Option A can't find it yet (new Java versions don't reach distribution repositories right away). Adoptium is an official Eclipse project providing prebuilt OpenJDK binaries; replace 21 with 25 in the commands below if that's the version you need.
Debian/Ubuntu (apt):
sudo apt update
sudo apt install -y wget apt-transport-https gpg
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print $2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
sudo apt update
sudo apt install -y temurin-21-jreAlmaLinux/Rocky Linux (dnf):
sudo tee /etc/yum.repos.d/adoptium.repo > /dev/null <<EOF
[Adoptium]
name=Adoptium
baseurl=https://packages.adoptium.net/artifactory/rpm/$(. /etc/os-release; echo $ID)/\$releasever/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://packages.adoptium.net/artifactory/api/gpg/key/public
EOF
sudo dnf install -y temurin-21-jreVerify the installation (either option):
java -versionThe output should contain openjdk version "21... (or "25... if you installed Java 25).
Step 2. Create a user, download server.jar
You shouldn't run a game server as root — create a dedicated system user with a home directory for the server:
sudo useradd -r -m -d /opt/minecraft -s /bin/bash minecraft-r— a system (service) account;-m -d /opt/minecraft— create/opt/minecraftand use it as the home directory;-s /bin/bash— a regular shell: you'll need it in Step 6 for the tmux/screen option (the shell doesn't matter for systemd).
Switch to this user — the commands up through Step 6 (systemd) run as this user, and you'll land in /opt/minecraft automatically:
sudo -iu minecraftDownload the jar for one of the two servers.
Option A: vanilla — the official Mojang server
- On your own computer, open minecraft.net/en-us/download/server and copy the link address for the server jar (right-click the download button → "Copy link address").
- On the VPS, still as
minecraft:
curl -L -o server.jar "<URL>"Option B: Paper — a higher-performance alternative with plugin support
Paper is a fork of the vanilla server with performance optimizations and support for Bukkit/Spigot plugins, fully compatible with the regular Minecraft client.
- Open papermc.io/downloads/paper, pick your Minecraft version, and copy the link for the latest build.
- On the VPS:
curl -L -o server.jar "<URL>"Step 3. Accept the license agreement — eula.txt
Run the server for the first time — it will create its configuration files and immediately exit, because the license hasn't been accepted yet:
java -jar server.jar --noguiThe log will show something like:
[...] [ServerMain/ERROR]: Failed to load properties from file: server.properties
[...] You need to agree to the EULA in order to run the server. Go to eula.txt for more info.A file named eula.txt will appear alongside it, with this content:
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
#<timestamp>
eula=falseOpen the file and change false to true:
nano eula.txteula=trueSave the file (in nano: Ctrl+O, Enter, then Ctrl+X).
Step 4. Configure server.properties
That same first run also created a server.properties file with default values:
nano server.propertiesThe settings that matter most for a first setup:
server-port(default25565) — the server's TCP port. Only change it if you know why — whatever port you set here is the one you'll need to open in the firewall in Step 7.difficulty(easy) — world difficulty:peaceful,easy,normal, orhard.gamemode(survival) — the default game mode:survival,creative,adventure, orspectator.max-players(20) — the maximum number of players at once.motd(A Minecraft Server) — the line players see in the server list.white-list(disabled by default) — turns on the whitelist: only players added with/whitelist add <name>in the server console can join.online-mode(true) — the server verifies players against Mojang/Microsoft accounts.
view-distance(10) — how many chunks around each player the server loads and sends to the client.simulation-distance(10) — how far from players the server simulates mobs and mechanics (redstone, etc.).
An example of the resulting lines in the file:
motd=mHost Minecraft server
difficulty=normal
max-players=10
view-distance=8Save the file the same way you saved eula.txt.
Step 5. Build a startup script: the -Xmx/-Xms memory flags
-Xms— the initial size of the Java heap at startup.-Xmx— the maximum heap size the process is allowed to use.
It's a good idea to set -Xms equal to -Xmx — that way Java allocates all the memory up front instead of spending time growing the heap while the game is running. Leave the operating system at least ~1 GB of free memory on top of whatever you assign to -Xmx.
For example, on a VPS with 4 GB of RAM, it's reasonable to assign 3 GB to a server with a few players:
-Xms3G -Xmx3GFor a vanilla server with a few players, a comfortable minimum is 2 GB and up; Paper with plugins or a larger player count may need noticeably more — go by the actual load you observe.
Create a startup script called start.sh — you'll use it for both systemd and tmux/screen (Step 6):
nano start.sh#!/bin/sh
cd "$(dirname "$0")"
exec java -Xms3G -Xmx3G -jar server.jar --noguiMake the script executable and test it by hand:
chmod +x start.sh
./start.shAfter a while the log will show a line like Done (12.345s)! For help, type "help" — the server is up and ready for connections. Type stop and press Enter to shut it down cleanly (the world gets saved) and return to the console:
stopStep 6. Run the server permanently: systemd or tmux/screen
Right now the server only runs manually in your current SSH session — it stops the moment you disconnect. Pick one of the two options below to fix that.
Option A: systemd (recommended)
Gives you systemctl management, autostart after a VPS reboot, and automatic restart on a crash. The trade-off: without RCON, the server has no interactive console — in-game commands only come from chat (with operator rights) or get scheduled ahead of time.
Create the unit:
sudo nano /etc/systemd/system/minecraft.service[Unit]
Description=Minecraft Java Edition server
After=network.target
[Service]
Type=simple
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/opt/minecraft/start.sh
Restart=on-failure
RestartSec=10
TimeoutStopSec=60
[Install]
WantedBy=multi-user.targetRestart=on-failure— restart automatically if the server crashes, but not after a normal stop via thestopcommand orsystemctl stop.TimeoutStopSec=60— how many seconds to wait for a clean shutdown before killing the process outright. Increase it for large worlds — saving can take longer.
Enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft
sudo systemctl status minecraftWatch the server log through journalctl:
sudo journalctl -u minecraft -fOnly stop the server this way:
sudo systemctl stop minecraftCheck that autostart is enabled:
systemctl is-enabled minecraftIt should say enabled.
Option B: tmux or screen (when you need a live console)
The process runs inside a detachable terminal session — you get direct access to the server console and can type commands like save-all, whitelist add, or stop straight in. The trade-off: without extra setup, there's neither autostart after a reboot nor automatic restart on a crash.
Install tmux if it isn't there yet:
sudo apt install -y tmux # Ubuntu/Debian
sudo dnf install -y tmux # AlmaLinux/Rocky LinuxStart a session as the minecraft user:
sudo -iu minecraft
tmux new -s minecraft
./start.shDetach from the session without stopping the server: Ctrl+B, then D. To get back to the server console later:
sudo -iu minecraft
tmux attach -t minecraftTo stop the server cleanly, reattach to the session, type stop, and press Enter.
sudo crontab -u minecraft -eAdd the line:
@reboot sleep 30 && /usr/bin/tmux new -d -s minecraft /opt/minecraft/start.shBut if what you actually want is autostart plus automatic restart on a crash out of the box, that's exactly what Option A (systemd) gives you.
Step 7. Open port 25565 in the firewall
Clients connect to the server over TCP port 25565 (or a different one, if you changed server-port in Step 4) — open it in the firewall.
Ubuntu/Debian (ufw):
sudo ufw allow 25565/tcpFor more on setting up ufw, see "The ufw firewall".
AlmaLinux/Rocky Linux (firewalld):
sudo firewall-cmd --permanent --add-port=25565/tcp
sudo firewall-cmd --reloadWhat's next
- The main thing worth backing up regularly is the
world/folder (andworld_nether/,world_the_end/, if they've been generated) inside/opt/minecraft. The simplest way to set up regular backups is the "rsync backups" article. - To manage player access and rights without creating separate accounts for them on the VPS itself, use the whitelist (
white-list+/whitelist add, Step 4) and operator rights (/op <name>from the server console). - If the VPS is running several services and memory is getting tight, check the overall load with
htop/free -hand recalculate-Xmx(Step 5) to account for the other processes.