MHOSTMHOST

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 root or a user with sudo rights.
  • 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.
Tip: the commands below are given with sudo. If you're already connected as root and there's no sudo on the system, run the same commands without the sudo prefix.

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.x numbering) — 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.
Verify: the exact requirement can change with each release — before installing, check the download page for the specific version you're about to install: minecraft.net/en-us/download/server for the vanilla server, papermc.io/downloads/paper for Paper. Java 21 covers the whole 1.20.5–1.21.x line; the newest 2026 releases (26.1 and up) already need Java 25 — the commands below are identical for both versions, only the number changes.

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:

bash
sudo apt update
sudo apt install -y openjdk-21-jre-headless

AlmaLinux/Rocky Linux 9:

bash
sudo dnf install -y java-21-openjdk-headless
Tip: the *-jre-headless package is just the Java runtime, with no GUI support and no JDK compiler tools. That's enough to run the server — you don't need the full JDK.

Option 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):

bash
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-jre

AlmaLinux/Rocky Linux (dnf):

bash
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-jre

Verify the installation (either option):

bash
java -version

The output should contain openjdk version "21... (or "25... if you installed Java 25).

Done: java -version shows the version you need — time to download the server.

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:

bash
sudo useradd -r -m -d /opt/minecraft -s /bin/bash minecraft
  • -r — a system (service) account;
  • -m -d /opt/minecraft — create /opt/minecraft and 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:

bash
sudo -iu minecraft

Download the jar for one of the two servers.

Option A: vanilla — the official Mojang server

  1. 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").
  2. On the VPS, still as minecraft:
bash
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.

  1. Open papermc.io/downloads/paper, pick your Minecraft version, and copy the link for the latest build.
  2. On the VPS:
bash
curl -L -o server.jar "<URL>"
Tip: for automation, Paper provides an official downloads API (https://fill.papermc.io/v3, documented at https://fill.papermc.io/swagger-ui/) that returns JSON with build links. For a one-time setup, using the link from the downloads page as shown above is simpler.
Verify: the downloaded file's name may differ from server.jar (it may include a version and build number, for example) — rename it so the rest of the commands in this article work unchanged, e.g. mv paper-*.jar server.jar.

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:

bash
java -jar server.jar --nogui

The 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:

properties
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
#<timestamp>
eula=false
Important: eula=true means you have read and accepted Mojang/Microsoft's Minecraft license agreement. Without it, the server won't start no matter what else you configure.

Open the file and change false to true:

bash
nano eula.txt
properties
eula=true

Save 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:

bash
nano server.properties

The settings that matter most for a first setup:

  • server-port (default 25565) — 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, or hard.
  • gamemode (survival) — the default game mode: survival, creative, adventure, or spectator.
  • 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.
Important: don't turn off online-mode unless you really need to. online-mode=false lets anyone join under any name without a license check — this opens the door to cheaters and is generally considered an unsafe setting.
  • 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.).
Tip: on a VPS with limited RAM/CPU, lower view-distance and simulation-distance (to 6–8, for example) — this noticeably cuts load with little impact on playability.

An example of the resulting lines in the file:

properties
motd=mHost Minecraft server
difficulty=normal
max-players=10
view-distance=8

Save 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 -Xmx3G

For 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):

bash
nano start.sh
bash
#!/bin/sh
cd "$(dirname "$0")"
exec java -Xms3G -Xmx3G -jar server.jar --nogui
Tip: the exec in the script replaces the shell process with the Java process instead of spawning it as a child — this matters for systemd (Step 6): it tracks and signals the exact process launched by ExecStart, and without exec that would be the shell script, not the server itself.

Make the script executable and test it by hand:

bash
chmod +x start.sh
./start.sh

After 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:

stop
Done: the server starts with ./start.sh and stops cleanly with stop — time to set it up to run permanently.

Step 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:

bash
sudo nano /etc/systemd/system/minecraft.service
ini
[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.target
  • Restart=on-failure — restart automatically if the server crashes, but not after a normal stop via the stop command or systemctl 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:

bash
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft
sudo systemctl status minecraft

Watch the server log through journalctl:

bash
sudo journalctl -u minecraft -f

Only stop the server this way:

bash
sudo systemctl stop minecraft
Tip: systemctl stop sends the process a SIGTERM signal, and the Minecraft server (both vanilla and Paper) has a built-in handler for it — it saves the world and shuts down cleanly, which you can see in the log as Saving worlds / Saving chunks lines. Confirm this once with journalctl -u minecraft right after running stop — after that you can stop the server this way with confidence.
Important: don't kill the process with kill -9 / systemctl kill -s SIGKILL unless you really have to — that skips saving the world and can corrupt your data.

Check that autostart is enabled:

bash
systemctl is-enabled minecraft

It 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:

bash
sudo apt install -y tmux   # Ubuntu/Debian
sudo dnf install -y tmux   # AlmaLinux/Rocky Linux

Start a session as the minecraft user:

bash
sudo -iu minecraft
tmux new -s minecraft
./start.sh

Detach from the session without stopping the server: Ctrl+B, then D. To get back to the server console later:

bash
sudo -iu minecraft
tmux attach -t minecraft

To stop the server cleanly, reattach to the session, type stop, and press Enter.

Tip: screen works just as well instead of tmux — the commands are similar: screen -S minecraft to create a session, Ctrl+A then D to detach, screen -r minecraft to reattach.
Tip: to have the tmux session with the server come back after a VPS reboot too, add a @reboot cron job for the minecraft user:
bash
sudo crontab -u minecraft -e

Add the line:

@reboot sleep 30 && /usr/bin/tmux new -d -s minecraft /opt/minecraft/start.sh

But 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):

bash
sudo ufw allow 25565/tcp

For more on setting up ufw, see "The ufw firewall".

AlmaLinux/Rocky Linux (firewalld):

bash
sudo firewall-cmd --permanent --add-port=25565/tcp
sudo firewall-cmd --reload
Done: the port is open — the server is reachable at <VPS_IP>:25565. If you're using the standard port (25565), the Minecraft client only needs the IP address, with no port.

What's next

  • The main thing worth backing up regularly is the world/ folder (and world_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 -h and recalculate -Xmx (Step 5) to account for the other processes.