Kategorie: Linux

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:

apt-get update -y
apt-get upgrade -y

The next step is to install git

apt-get install git build-essential -y

Time for java installation will be done with the command:

apt-get install openjdk-11-jre-headless -y

Java versions can be verified by issuing a command:

java -version

the result of the:

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:

useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft

We are migrating to this user:

its - minecraft

We create catalogs:

mkdir ~/backups ~/tools ~/server

The next step is to install mcron. We download it by issuing a command:

git clone https://github.com/Tiiffi/mcrcon.git ~/tools/mcrcon

Next:

cd ~/tools/mcrcon
gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c

We download the minecraft server

wget https://launcher.mojang.com/v1/objects/a0d03225615ba897619220e256a266cb33a44b6b/server.jar -P ~/server

We can run it:

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:

[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

nano ~/server/eula.txt

And we change from false to true

eula=true

The next step is to set the rcon password

edit file:

nano ~/server/server.properties

And configure as follows entering your password:

rcon.password=NASZEHASŁO
enable-rcon=true 

We're creating a service daemon:

nano /etc/systemd/system/minecraft.service

The content:

[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:

systemctl daemon-reload
systemctl start minecraft
systemctl enable minecraft

After checking the status by command:

systemctl status minecraft

We should now see our minecraft server running:

 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:

/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p NASZEHASLO -t

Linux

Udostępnij
Opublikowane przez
Linux

Recent posts

KeePass2 2.52 w Ubuntu 22.04

The guide below describes how to install KeePass on Ubuntu. Całość wykonamy za pomocą kilku poleceń

2 years temu

Installing Master PDF editor in Ubuntu 22.04

Master PDF Editor is a comprehensive PDF program, which includes many features. Oprócz tworzenia i edycji

2 years temu

iotop - memory monitoring

Iotop jest prostym narzędziem dla systemów Uniksowych umożliwiającym monitorowanie użycia dowolnego nośnika pamięci flash/hdd/ssd w

2 years temu

Run multiple commands in one cron job

You can separate two or more commands with semicolons (;), Semicolon (;): służy do oddzielania

2 years temu

Changing the exif data of a photo in the Linux terminal

Poniższy poradnik opisuje w jaki sposób za pomocą konsoli możemy dokonać edycji danych zdjęcia exif.

2 years temu

Installing Rocket.Chat Server on Rocky Linux 8

The following guide describes how to install Rocket.Chat on Rocky Linux 8 Całość bardzo prosto zainstalujemy

2 years temu