Minecraft Server

This page is a guide how to install the Minecraft server on Debian-based Linux distribution.

The steps in this guide are only prompts to the desired result, do not follow them stupid and read manuals before do something.

Network setup

Open the 25565/TCP port on your router to connect to your server.

Server setup

Create a Minecraft user:

# adduser --system --group minecraft-server

This is a system user, it means that you will not have remote access.

Add the non-root user to the minecraft group to access the server files:

# adduser $username minecraft-server

Create a server directory and change owner and group permissions:

# mkdir /srv/minecraft-server
# chown minecraft-server:minecraft-server /srv/minecraft-server
# chmod 770 /srv/minecraft-server

Install Oracle JDK

Download the latest version JDK package.deb from Oracle official website.

Then install it dpkg package management tool (replace X character to your version number).

# dpkg -i ./jdk-X_linux-x64_bin.deb

Download server

Download the server.jar from Minecraft official website or another server platform and put in /srv/minecraft-server directory.

Create systemd service

Copy this systemd service file as /etc/systemd/system/minecraft-server.service:

[Unit] 
Description=Minecraft Server

[Service]
WorkingDirectory=/srv/minecraft-server
User=minecraft-server
Group=minecraft-server
Restart=on-failure
RestartSec=60
ExecStart=/usr/bin/java -Xmx2G -jar server.jar --nogui

[Install]
WantedBy=multi-user.target

Restart the systemd daemon and check errors:

# systemctl daemon-reload

Enable (autorun) and start service:

# systemctl enable --now minecraft-server.service

Agree with Minecraft End(er)-User License Agreement ("EULA"):

$ echo "eula=true" > eula.txt

Change server configuration

Edit server.properties file in server directory:

$ vim server.properties

Enable server remote control and set *your_password*:

enable-rcon=true
rcon.password=*your_password*

Enable server whitelist:

white-list=true

Restart the server:

# systemctl restart minecraft-server.service

Remote control

Install RCON client

# apt install rcon

Connect to server locally:

$ rconshell localhost:25575

Or from remote-machine:

$ ssh remote-machine rconshell localhost:25575

Do not open RCON port to remote server control. Instead use RCON connection under SSH.