Site icon Learning & Doing

Cara Membuat Minecraft Server pada Ubuntu 20.04 / Debian 11 / Linux Mint

minecraft

“Cara Membuat Minecraft Server pada Ubuntu 20.04 / Debian 11 / Linux Mint”

Pendahuluan

Minecraft adalah salah satu game paling populer sepanjang masa. Ini adalah video game kotak pasir di mana pemain menjelajahi dunia tanpa batas dan membangun struktur yang berbeda dari rumah sederhana hingga gedung pencakar langit yang menjulang tinggi.

Persyaratan

sudo apt update
sudo apt install git build-essential

Install Java Runtime Environment

sudo apt install openjdk-11-jre-headless
java -version

Membuat User Minecraft

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

Install Minecraft Server pada Ubuntu 20.04 / Debian 11 / Linux Mint

sudo su - minecraft
mkdir -p ~/{backups,tools,server}

Download dan Compiling mcron

git clone https://github.com/Tiiffi/mcrcon.git ~/tools/mcrcon
cd ~/tools/mcrcon
gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c

./mcrcon -v

Download Minecraft Server

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

Konfigurasi Minecraft Server

cd ~/server
java -Xmx1024M -Xms1024M -jar server.jar nogui

Hasil tampilan

[17:35:14] [main/ERROR]: Failed to load properties from file: server.properties
[17:35:15] [main/WARN]: Failed to load eula.txt
[17:35:15] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
nano ~/server/eula.txt
eula=true
nano ~/server/server.properties
rcon.port=25575
rcon.password=strong-password
enable-rcon=true

Membuat service systemd

sudo nano /etc/systemd/system/minecraft.service
[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 strong-password stop

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start minecraft

sudo systemctl status minecraft

sudo systemctl enable minecraft

Allow Firewall

sudo ufw allow 25565/tcp

Buat Configurasi Backup

sudo su - minecraft
nano /opt/minecraft/tools/backup.sh

Tambahkan script berikut

#!/bin/bash

function rcon {
  /opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p strong-password "$1"
}

rcon "save-off"
rcon "save-all"
tar -cvpzf /opt/minecraft/backups/server-$(date +%F-%H-%M).tar.gz /opt/minecraft/server
rcon "save-on"

## Delete older backups
find /opt/minecraft/backups/ -type f -mtime +7 -name '*.gz' -delete
chmod +x /opt/minecraft/tools/backup.sh
crontab -e
0 23 * * * /opt/minecraft/tools/backup.sh

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Cara Membuat Minecraft Server pada Ubuntu 20.04 / Debian 11 / Linux Mint. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

Exit mobile version