In this tutorial, we will show you how to install the Minecraft server on Debian 9 Stretch. For those of you who didn’t know, Minecraft is a game about breaking and placing blocks. The creative and building aspects of Minecraft allow players to build constructions out of textured cubes in a 3D procedurally generated world. Minecraft servers allow players to play online or via a local area network with other people. They may either be run on a hosted server, on local dedicated server hardware, on a Virtual Private server on a home machine, or on your local gaming computer.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Minecraft Server on a Debian 9 Stretch server.
Prerequisites
- A server running one of the following operating systems: Debian 9 (Stretch).
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Minecraft Server on Debian 9 Stretch
Step 1. First, make sure that all your system packages are up-to-date by running the following apt-get
commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install git build-essential
Step 2. Installing Java-JDK.
Minecraft server setup requires Java to be installed on your system:
sudo apt install openjdk-8-jre-headless
Verify the installation by printing the java version:
java -version
Step 3. Installing Minecraft Server on Debian 9.
First, run the following command to create three new directories inside the user home directory:
mkdir -p ~/{backups,tools,server}
Next, Downloading and Compiling mcrcon
:
cd ~/tools && git clone https://github.com/Tiiffi/mcrcon.git cd ~/tools/mcrcon gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c ./mcrcon -h
Then, Downloading Minecraft Server:
wget https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar -P ~/server
Step 4. Configuring Minecraft Server.
Once the download is completed, navigate to the ~/server directory and start the Minecraft server:
cd ~/server java -Xmx1024M -Xms512M -d64 -jar server.jar nogui
Next, Open the eula.txt file and change eula=false to eula=true:
### nano ~/server/eula.txt #By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula). #Thu Dec 27 03:33:56 PST 2018 eula=true
Then, edit the server.properties file to enable the rcon
protocol and set the rcon
password. You can use this setting to connect to the Minecraft server using the mcrcon
tool:
### nano ~/server/server.properties rcon.port=23888 rcon.password=your-strong-password enable-rcon=true
Step 5. Creating Systemd.
To run Minecraft as a service we will create a new Systemd unit file:
sudo nano /etc/systemd/system/minecraft.service
Paste the following file:
[Unit] Description=Minecraft Server After=network.target [Service] User=minecraft Nice=1 KillMode=none SuccessExitStatus=0 1 ProtectHome=true ProtectSystem=full PrivateDevices=true NoNewPrivileges=true WorkingDirectory=/opt/minecraft/server ExecStart=/usr/bin/java -Xmx1024M -Xms512M -jar server.jar nogui --noconsole ExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 23888 -p strong-password stop [Install] WantedBy=multi-user.target
Save and close the file and notify systemd
that we created a new unit file:
sudo systemctl daemon-reload sudo systemctl start minecraft
Step 6. Configure Firewall.
If your server is protected by a firewall and you want to access the Minecraft server from the outside of your local network you need to open port 25565:
sudo ufw allow 25565/tcp
Step 7. Accessing Minecraft Console.
To access the Minecraft Console you can use the mcrcon
utility. The syntax is as follows, you need to specify the host, rcon
port, rcon
password and use the -t switch which enables the mcrcon
terminal mode:
/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 23888 -p strong-password -t
Congratulations! You have successfully installed Minecraft. Thanks for using this tutorial for installing the Minecraft server on Debian 9 (Stretch) system. For additional help or useful information, we recommend you check the official Minecraft website.