How to Install Minecraft Server on Debian 11

Choose a different version or distribution

Introduction

Before we begin talking about how to install Minecraft Server on Debian 11, let's briefly understand – What is Minecraft?

Minecraft is an immensely popular sandbox video game that lets players unleash their creativity and explore virtual worlds. Created by Mojang Studios, Minecraft offers endless possibilities, allowing players to build structures, mine resources, and embark on thrilling adventures. Its pixelated graphics and simple gameplay have captivated millions of players worldwide.

Whether you're constructing elaborate castles, surviving against hostile creatures, or collaborating with friends in multiplayer mode, Minecraft offers a captivating and immersive experience that has become a cultural phenomenon. Discover the limitless potential of Minecraft and let your imagination soar in this extraordinary virtual universe.

Advantages of Minecraft Server

  1. Creativity: Minecraft allows players to express their creativity by building and designing unique structures and landscapes.
  2. Exploration: With vast, procedurally generated worlds to discover, players can embark on exciting adventures and uncover hidden treasures.
  3. Multiplayer: Join forces with friends or connect with players worldwide, collaborating on massive construction projects or engaging in thrilling PvP battles.
  4. Educational: Minecraft promotes critical thinking, problem-solving, and resource management skills, making it a valuable educational tool for both children and adults.
  5. Endless Replayability: With its open-ended gameplay and a thriving modding community, Minecraft offers limitless possibilities, ensuring no two experiences are the same.

Prerequisites to Install Minecraft Server on Debian 11

  • Install a Debian 11 server instance with at least 2 GB of memory, which can accommodate up to 10 players with some simple plugins or mods.

Step 1 – Harden the System

Open your preferred SSH client on your desktop machine, such as PuTTY for Windows, and use the first password you acquired on the Server Details page to log in as root to your server instance.

To harden the system, perform the following actions after login in.

Check to see whether any swap partitions or swap files are active:

swapon -s

If yes, feel free to move on to the next task. If not, configure a 2GB swap file to improve system performance:

fallocate -l 2g /swap
chmod 0600 /swap
mkswap /swap
swapon /swap
echo '/swap    none swap defaults 0 0' | tee -a /etc/fstab
free -m

Change the default root password to something secure and confidential, like r00tyGvM%2ka$8D7:

sudo echo 'root:r00tyGvM%2ka$8D7' | sudo chpasswd && history -d -1

Make a non-root user account with sudo privileges, for example, mcninja, and then give it a strong password like sud07FeXbcx#3&Cw:

sudo su
useradd -ms /bin/bash mcninja
echo 'mcninja:sud07FeXbcx#3&Cw' | chpasswd && history -d -1
echo 'mcninja    ALL=(ALL)   NOPASSWD: ALL' | tee -a /etc/sudoers.d/designated
chmod 0440 /etc/sudoers.d/designated

Configure UFW firewall rules to only permit traffic on SSH (22) and default Minecraft (25565) ports:

sudo apt update
sudo apt install ufw
ufw default deny
ufw allow 22
ufw allow 25565
ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y [ENTER]
ufw status verbose

Reboot after updating the system:

apt update
apt upgrade -y
apt autoremove -y
shutdown -r now

Log in as the newly created sudo user mcninja for the upcoming steps after the server instance restarts.

Step 2 – Install the Temurin 17 OpenJDK Distribution

Java 17 is needed for the Minecraft Java Edition server 1.18.2. In this tutorial, we chose to install Temurin (the continuation of AdoptOpenJDK) 17 OpenJDK binaries from Eclipse Adoptium, from among numerous Java 17 distributions.

Ensure that the necessary packages are accessible:

sudo apt install wget apt-transport-https -y

To verify packages, download the Eclipse Adoptium GPG key:

wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /usr/share/keyrings/adoptium.asc

Configure the Eclipse Adoptium Advanced Packaging Tool (APT) repository as follows:

echo "deb [signed-by=/usr/share/keyrings/adoptium.asc] 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

Get the Temurin 17 OpenJDK:

sudo apt update
sudo apt install temurin-17-jdk -y

Add Temurin 17 OpenJDK to the PATH environment variable after setting up the JAVA_HOME environment variable:

echo "export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")" | sudo tee -a /etc/profile && source /etc/profile
echo "export PATH=$PATH:$JAVA_HOME/bin" | sudo tee -a /etc/profile && source /etc/profile
echo $JAVA_HOME
echo $PATH

Verify that Temurin 17 OpenJDK is installed:

java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

Step 3 – Install Minecraft Java Edition Server 1.18.2

Set up a directory for the Minecraft Java Edition server:

sudo mkdir /opt/minecraft
sudo chown mcninja:mcninja /opt/minecraft

Use the download link from the official Minecraft Java Edition Server Download page to get the latest version of the Minecraft Java Edition server, 1.18.2.

cd /opt/minecraft
wget https://launcher.mojang.com/v1/objects/c8f83c5655308435b3dcf03c06d9fe8740a77469/server.jar -O minecraft_server.1.18.2.jar

To signify your acceptance of the Minecraft end-user license agreement, create the following text file:

echo "eula=true" > /opt/minecraft/eula.txt

Try out the Minecraft Java Edition server 1.18.2:

cd /opt/minecraft
java -Xms1024M -Xmx1024M -jar /opt/minecraft/minecraft_server.1.18.2.jar nogui
...
⚠️
The previous command's -Xms1024M and -Xmx1024M flags specify the Minecraft Java Edition server's initial and maximum memory allocation values, respectively. In this situation, they are both 1024M. These two values are acceptable for a Debian 11 server instance with 2GB of memory. If your server instance has extra memory, you might want to increase the values.

The server is fully operational when you see the prompt Done!:

  • Start your Minecraft client.
  • Add the server name and IPv4 address, for example, 203.0.113.100.
  • Explore the recently constructed world by joining the server.

After the test run, terminate the Minecraft Java Edition server 1.18.2 by pressing CTRL + C in the SSH terminal.

You need to modify a freshly generated file called server.properties located in the Minecraft Java Edition server directory in order to personalize your Minecraft Java Edition server.

For instance, if you want to make it possible for non-premium players to access your Minecraft server:

nano /opt/minecraft/server.properties

Locate the line:

online-mode=true

Replace it with:

online-mode=false

To save your changes and exit, press CTRL+O, ENTER, and CTRL+X. To load the updated settings, restart the Minecraft Java Edition server after that.

Visit the Minecraft Wiki article to find out more about configuring Minecraft server properties.

Step 4 – Install Supervisor

It is advised to use the Supervisor application to automatically start and restart the Minecraft Java Edition server processes in order to keep the server functioning.

Get the Supervisor program installed:

sudo apt install supervisor -y
supervisord -v

Launch the Supervisor service:

sudo systemctl daemon-reload
sudo systemctl start supervisor.service
sudo systemctl enable supervisor.service

Create a Supervisor configuration file for the Minecraft Java Edition server by following these steps:

sudo nano /etc/supervisor/conf.d/minecraft.conf

Fill up the file with:

[program:minecraft]
directory=/opt/minecraft/
command=java -Xms1024M -Xmx1024M -jar /opt/minecraft/minecraft_server.1.18.2.jar nogui
user=mcninja
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/error_minecraft.log
stderr_logfile_maxbytes=100MB
stdout_logfile=/var/log/supervisor/out_minecraft.log
stdout_logfile_maxbytes=100MB

To save the configuration file and end the program, click CTRL+O, ENTER, and CTRL+X.

Install the Minecraft Java Edition server configuration file:

sudo supervisorctl reread
sudo supervisorctl update

Check to see if the Minecraft Java Edition server is operational:

tail -f /var/log/supervisor/out_minecraft.log
...
[08:15:49] [Server thread/INFO]: Done (123.024s)! For help, type "help"

To end the tail program at any point, press CTRL+C.

FAQs to Set Up Minecraft Server on Debian 11

How do I install Java on Debian 11 for Minecraft server setup?

Run the command sudo apt install openjdk-11-jdk to install Java Development Kit (JDK) on Debian 11.

How can I allocate more RAM to the Minecraft server on Debian 11?

Edit the server startup script and modify the -Xmx parameter, setting it to the desired amount of RAM (e.g., "-Xmx4G" for 4GB).

How do I enable port forwarding on Debian 11 for Minecraft server?

Access your router's settings, locate the port forwarding section, and forward the default Minecraft server port (25565) to the local IP address of the Debian 11 machine.

Can I run a Minecraft server on Debian 11 without a GUI?

Yes, Minecraft servers can be run in a headless environment without a graphical user interface.

Can I automate Minecraft server startup on system boot in Debian 11?

Yes, create a systemd service unit for the Minecraft server and enable it with the command: sudo systemctl enable minecraft-server.

How do I whitelist players on a Minecraft server running on Debian 11?

Edit the whitelist.json file and add the players' Minecraft usernames, one per line, to restrict server access to authorized players only.

How can I monitor the performance of a Minecraft server on Debian 11?

Use tools like Minecraft Server Dashboard or server management plugins to monitor server metrics such as CPU, memory usage, and player activity.


Conclusion

You now know how to install a Minecraft server on Debian 11. For more information, visit Minecraft Java Edition Server Download Page and Minecraft Wiki.

If you have any queries, or doubts, please leave in the comment below. We'll be happy to address them.