If you are using Paper 1.17, you must include the Note
-DPaper.IgnoreJavaVersion=true
flag because Paper did not officially support Java 17 yet.Debian / Ubuntu
Setup a PaperMC Minecraft server and complete initial configuration on a Debian-based system.
Initial System Setup completed.
Logged in as administrative user.
Before getting started, update package repositories and apply upgrades for the latest patches.
# Debian
sudo apt update
sudo apt upgrade
Minecraft utilizes Java and requires a Java Runtime Environment (JRE) to be installed on the system. If you intend on running Minecraft 1.17+, make sure you install Java version 16 or higher.
OpenJDK is an open-source implementation of the Java Platform SE, distributed under the GPLv2 license. If you wish to use OracleJDK instead, be aware you must purchase a license for commercial and production use. Select the OpenJDK version below for your desired Minecraft release.
# Minecraft 1.16.5 - 1.20.x (OpenJDK 17 LTS)
sudo apt install openjdk-17-jre-headless
# Minecraft 1.12 - 1.16.4 (OpenJDK 11 LTS)
sudo apt install openjdk-11-jre-headless
# Minecraft 1.8 - 1.11 (OpenJDK 8 LTS)
sudo apt install openjdk-8-jre-headless
Verify that Java installed without issue by checking the version.
java -version
If all is well, the status should resemble the following.
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.2+8-Debian-1deb11u1, mixed mode, sharing)
Add a new minecraft
system user and map the home directory to /opt/minecraft
.
sudo useradd --system --user-group --create-home --home /opt/minecraft --shell /sbin/nologin minecraft
Execute commands as the user using su
.
sudo su -s /bin/bash minecraft -c "COMMAND_TO_RUN"
Alternatively, switch to the user with su
.
sudo su -s /bin/bash - minecraft
Create a few required directories (backups, bin, log, server) in the /opt/minecraft
directory.
mkdir /opt/minecraft/{backups,bin,log,server}
With Java installed, and your server properly caffeinated, its time to install Minecraft. This bit covers the process for installing PaperMC, instead of the vanilla release from Mojang. PaperMC provides extra configuration options, offers performance improvements, and allows you to install Paper / Spigot / Bukkit plugins. This is a server-side change, and requires no additional configuration for users client-side. Learn more about PaperMC at papermc.io.
As stated previously, PaperMC is an alternative Minecraft Server release that provides increased functionality. Should you wish to use the official release instead, the latest version can be found at minecraft.net/download/server.
Download PaperMC to the /opt/minecraft/server
directory. The latest version can be found at papermc.io/downloads, and a list of download links for previous versions can be found at papermc.io/legacy. A few different versions are listed below. The rest of this bit will assume version 1.18.1 was used, but the process is the same for all modern releases.
# Minecraft 1.20.2
wget https://api.papermc.io/v2/projects/paper/versions/1.20.2/builds/217/downloads/paper-1.20.2-217.jar --directory-prefix /opt/minecraft/server
# Minecraft 1.18.2
wget https://api.papermc.io/v2/projects/paper/versions/1.18.2/builds/388/downloads/paper-1.18.2-388.jar --directory-prefix /opt/minecraft/server
# Minecraft 1.16.5
wget https://api.papermc.io/v2/projects/paper/versions/1.16.5/builds/794/downloads/paper-1.16.5-794.jar --directory-prefix /opt/minecraft/server
# Minecraft 1.12.2
wget https://api.papermc.io/v2/projects/paper/versions/1.12.2/builds/1620/downloads/paper-1.12.2-1620.jar --directory-prefix /opt/minecraft/server
Rename the downloaded jar
file to paper.jar
for ease of use in commands and configuration.
mv /opt/minecraft/server/paper-1.20.2-217.jar /opt/minecraft/server/paper.jar
Start Paper to create the eula.txt
and server.properties
files. You will receive warning and error messages, this is expected behavior.
-DPaper.IgnoreJavaVersion=true
flag because Paper did not officially support Java 17 yet.java -Xmx1024M -Xms512M -jar /opt/minecraft/server/paper.jar nogui
The output will resemble the following.
Loading libraries, please wait...
[02:22:20 ERROR]: Failed to load properties from file: server.properties
[02:22:20 WARN]: Failed to load eula.txt
[02:22:20 INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
MCRCON is an implementation of the RCON (Remote CONsole) protocol designed specifically for Minecraft. MCRCON will allow you to execute console commands via scripts, as other system users, and from remote systems.
Create an mcrcon
directory in the /opt/minecraft/bin
directory. As the path suggests MCRCON will be installed here.
mkdir /opt/minecraft/bin/mcrcon
Download the latest release from MCRON’s GitHub repository. At the time of writing this was version 0.7.2. The most recent version can be found at github.com/Tiiffi/mcrcon/releases/latest.
wget https://github.com/Tiiffi/mcrcon/releases/download/v0.7.2/mcrcon-0.7.2-linux-x86-64.tar.gz --directory-prefix /tmp
Extract the downloaded release using tar
to the /opt/minecraft/bin/mcrcon
directory.
tar -xvf /tmp/mcrcon-0.7.2-linux-x86-64.tar.gz -C /opt/minecraft/bin/mcrcon
Set the permissions of the mcrcon
directory so only the minecraft
user / group can interact with it.
chmod -R 750 /opt/minecraft/bin/mcrcon
With Minecraft installed on your server, its time to configure a few things.
Start by accepting the Minecraft EULA. Open the eula.txt
file in your text editor of choice.
nano /opt/minecraft/server/eula.txt
After reading the Minecraft EULA, set eula=true
.
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#You also agree that tacos are tasty, and the best food in the world.
#Sun Nov 14 02:22:20 EST 2021
eula=true
Next up is the server.properties
file. This is where you will find all the default configurable options for your server. Configuration for enabling RCON is detailed below as it relates to MCRCON. Full customization of this is outside of the scope of this bit, please refer to the Minecraft Wiki for more information on what each option does. Open the server.properties
file in your text editor of choice.
nano server.properties
Find the lines relating to RCON and set them as follows. This will set the port, the password used to connect, and enable the remote console.
rcon.port=25575
rcon.password=Generated_Secure_Password
enable-rcon=true
Backups are important for a Minecraft server, especially if you are using plugins or opening it up to the public. In this section we will automate the process of creating daily backups that are stored for one week.
Start by creating a backup script in the /opt/minecraft/bin
directory.
nano /opt/minecraft/bin/backup.sh
Enter in the following template script and adjust it to suit your server. As written, the script will create a backup /opt/minecraft/server
as an archive named server-YYYY-MM-DD-HH-MM.tar.gz
and store it in /opt/minecraft/backups
. It will also delete any tar.gz
files in the backups directory that are older than 7 days.
Generated_Secure_Password
in the consolemc
function to match the password set in the server.properties
file.serverDir
, backupDir
, and dateFormat
if necessary.#!/bin/bash
# Minecraft Backup Script
# MCRCON Command
function consolemc {
/opt/minecraft/bin/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p Generated_Secure_Password "$1"
}
# Server Directory
serverDir="/opt/minecraft/server"
# Backup Directory
backupDir="/opt/minecraft/backups"
# Date Format (YYYY-MM-DD-HH-MM)
dateFormat=$(date +%F-%H-%M)
# File Prefix
filePrefix="minecraft-server-"
# Disable Disk Writes
consolemc "save-off"
# Flush Pending Writes
consolemc "save-all"
# Create Backup Archive
tar -cpzf $backupDir/$filePrefix$dateFormat.tar.gz $serverDir
# Enable Disk Writes
consolemc "save-on"
# Delete Backups (> 7 days old)
find $backupDir -type f -mtime +7 -wholename "$backupDir/$filePrefix*.tar.gz" -exec rm {} \;
Change the permissions of the script so only the minecraft
user can interact with it.
chmod 750 /opt/minecraft/bin/backup.sh
With the script setup, create a cron job to execute the script once a day. Open up the crontab
to configure this.
crontab -e
Add the following to the bottom of the file. This will execute the script you just created everyday at 3:00 AM, and create a log of the most recent script execution in /opt/minecraft/bin/backup.log
.
# Minecraft Backup Script
0 3 * * * /opt/minecraft/bin/backup.sh > /opt/minecraft/log/backup.log 2>&1
Time to configure some server processes. With Minecraft installed and basic setup complete, logout of the minecraft
user and switch back to your administrative account.
logout
Add your current user to the mincecraft
group, allowing it to navigate the /opt/minecraft
directory. By default, files and plugins need to be edited with the minecraft
user or sudo
.
sudo usermod -aG minecraft $USER
Before being able to connect to the server from a Minecraft game client, you must allow connections to port 25565
.
sudo ufw allow proto tcp to any port 25565
To better control the state of the Minecraft application, setup Minecraft as a service with a systemd
unit file. Create the file using your text editor of choice.
sudo nano /etc/systemd/system/minecraft.service
Enter in the following configuration and adjust it to suit your server. For more information about systemd
unit configuration, refer to the freedesktop.org documentation.
User=
and WorkingDirectory=
definitions are correct.Xmx1024M
and Xms512M
in ExecStart=
based on your available system RAM. The Xmx
flag is the maximum amount of RAM the Minecraft application can use, and the Xms
flag is the minimum amount. To allow Minecraft to use 8GB of RAM you could use Xmx8192M
and Xms2048M
. Set the maximum value to be at least 1GB lower than the total amount of RAM available on your system.Generated_Secure_Password
in ExecStop=
to match the password set in the server.properties
file.[Unit]
Description=Minecraft
After=network.target
[Service]
User=minecraft
WorkingDirectory=/opt/minecraft/server
Nice=1
SuccessExitStatus=0 1
NoNewPrivileges=true
ProtectSystem=full
ProtectHome=true
PrivateDevices=true
ExecStart=/usr/bin/java -Xmx1024M -Xms512M -jar paper.jar nogui
ExecStop=/opt/minecraft/bin/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p Generated_Secure_Password stop
[Install]
WantedBy=multi-user.target
Reload systemd
so it is aware of the changes made.
sudo systemctl daemon-reload
The Minecraft application can now be controlled with the systemctl
command. The restart
directive will not work, use the stop and start commands separately if you with to restart the server.
# Start Minecraft
sudo systemctl start minecraft
# Stop Minecraft
sudo systemctl stop minecraft
The Minecraft server is now setup and ready to go. Start installing plugins, and configuring everything to your heart’s desire.
To start a Minecraft console session with MCRCON, use the following command with the -t
flag. Replace Generated_Secure_Password
with the password set in the server.properties
file.
/opt/minecraft/bin/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p Generated_Secure_Password -t
To issue a single command without opening a console session, enter the command you wish to run instead of the -t
flag.
/opt/minecraft/bin/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p Generated_Secure_Password "stop"
Spin up the Minecraft launcher and make sure to use the same game version as your server. Head over to the Multiplayer
tab and select Add Server
. In the Server Address
field put the IP address of your server, or the domain name pointed at it, and select Done
. If you configured any port besides 25565
in the server.properties
file, you must specify that after the address. Your server will now be on the Play Multiplayer
list, simply select it and hit Join Server
.
Fandom. “Minecraft Wiki.” 2024. ↩︎