Installing Minecraft server on Ubuntu 20.04
The following guide describes how to install the Minecraft server on Ubuntu 20.04.
Made with just a few steps.
We log in to the console as root and update the repositories and system:
1 2 | apt-get update -y apt-get upgrade -y |
The next step is to install git
1 | apt-get install git build-essential -y |
Time for java installation will be done with the command:
1 | apt-get install openjdk-11-jre-headless -y |
Java versions can be verified by issuing a command:
1 | java -version |
the result of the:
1 2 3 | openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing) |
We go to the Minecraft server installation
At the beginning we add the user to the system:
1 | useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft |
We are migrating to this user:
1 | su - minecraft |
We create catalogs:
1 | mkdir ~/backups ~/tools ~/server |
The next step is to install mcron. We download it by issuing a command:
1 | git clone https://github.com/Tiiffi/mcrcon.git ~/tools/mcrcon |
Next:
1 2 | cd ~/tools/mcrcon gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c |
We download the minecraft server
1 | wget https://launcher.mojang.com/v1/objects/a0d03225615ba897619220e256a266cb33a44b6b/server.jar -P ~/server |
We can run it:
1 2 | cd ~/server java -Xmx1024M -Xms1024M -jar server.jar nogui |
Most likely, we will see the error of lack of license consent as in the log below:
1 2 3 | [07:46:12] [main/ERROR]: Failed to load properties from file: server.properties [07:46:12] [main/WARN]: Failed to load eula.txt [07:46:12] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info. |
edit file
1 | nano ~/server/eula.txt |
And we change from false to true
1 | eula=true |
The next step is to set the rcon password
edit file:
1 | nano ~/server/server.properties |
And configure as follows entering your password:
1 2 | rcon.password=NASZEHASŁO enable-rcon=true |
We're creating a service daemon:
1 | nano /etc/systemd/system/minecraft.service |
The content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [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 -Xms1024M -jar server.jar nogui ExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p NASZEHASŁO stop [Install] WantedBy=multi-user.target |
We're reloading the daemon and starting the service:
1 2 3 | systemctl daemon-reload systemctl start minecraft systemctl enable minecraft |
After checking the status by command:
1 | systemctl status minecraft |
We should now see our minecraft server running:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | minecraft.service - Minecraft Server Loaded: loaded (/etc/systemd/system/minecraft.service; disabled; vendor preset: enabled) Active: active (running) since Thu 2020-07-02 08:05:24 UTC; 1min 0s ago Main PID: 11704 (java) Tasks: 30 (limit: 4691) Memory: 1.0G CGroup: /system.slice/minecraft.service ??11704 /usr/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui Jul 02 08:06:06 ubuntu2004 java[11704]: [08:06:06] [Worker-Main-2/INFO]: Preparing spawn area: 94% Jul 02 08:06:06 ubuntu2004 java[11704]: [08:06:06] [Server thread/INFO]: Preparing spawn area: 95% Jul 02 08:06:07 ubuntu2004 java[11704]: [08:06:07] [Worker-Main-2/INFO]: Preparing spawn area: 96% Jul 02 08:06:07 ubuntu2004 java[11704]: [08:06:07] [Worker-Main-2/INFO]: Preparing spawn area: 96% Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Worker-Main-2/INFO]: Preparing spawn area: 99% Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Time elapsed: 26283 ms Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Done (26.613s)! For help, type "help" Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Starting remote control listener Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [Server thread/INFO]: Thread RCON Listener started Jul 02 08:06:08 ubuntu2004 java[11704]: [08:06:08] [RCON Listener #1/INFO]: RCON running on 0.0.0. |
We can start the minecraft console by issuing a command:
1 | /opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p NASZEHASLO -t |