Host

Hosting MeseCraft is easy. Building and configuring a dedicated MeseCraft server on Minetest is straightforward. This guide is mainly for Debian & Ubuntu Linux users.

Contents

SECTION 1: Installing the Server Software

STEP 1: Install dependencies.

Install necessary packages.

sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libxi-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev

STEP 2: Install Git.

sudo apt install git

STEP 3: Download Minetest source code and dependencies.

Create a directory, clone Minetest and its dependencies.

sudo mkdir /opt/mesecraft-server && cd /opt/mesecraft-server/
sudo git clone -b stable-5 --depth 1 https://github.com/minetest/minetest.git
cd minetest
sudo git clone --depth 1 https://github.com/minetest/irrlicht.git lib/irrlichtmt
sudo mkdir logs

STEP 4: Download MeseCraft game files.

sudo git clone --depth 1 https://github.com/MeseCraft/MeseCraft.git games/MeseCraft

STEP 5: Build Minetest.

Compile the server.

sudo cmake . -DRUN_IN_PLACE=TRUE -DBUILD_SERVER=TRUE -DBUILD_CLIENT=FALSE
sudo make install

SECTION 2: Configuring the Software

STEP 1: Create a new user.

Create a dedicated user for the server.

sudo adduser --system --no-create-home --group mesecraft-server

STEP 2: Set directory permissions.

sudo chown -R mesecraft-server:mesecraft-server /opt/mesecraft-server/

STEP 2.1: Set executable privileges on the minetest binary.

sudo chmod +x /opt/mesecraft-server/minetest/bin/minetestserver

STEP 3: Create the configuration file.

Copy and edit the config file.

sudo cp minetest.conf.example minetest.conf
sudo nano minetest.conf

STEP 4: Create a system service.

Create and enable a systemd service.

sudo nano /etc/systemd/system/mesecraft-server.service
[Unit]
Description=MeseCraft Server
After=network.target
RequiresMountsFor=/opt/mesecraft-server/minetest/worlds
[Service]
Restart=on-failure
User=mesecraft-server
Group=mesecraft-server
WorkingDirectory=/opt/mesecraft-server/minetest
ExecStart=/opt/mesecraft-server/minetest/bin/minetestserver --config /opt/mesecraft-server/minetest/minetest.conf --logfile /opt/mesecraft-server/minetest/logs/minetest.log
StandardOutput=null
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable mesecraft-server
sudo systemctl start mesecraft-server

SECTION 3: Maintaining Your Server

Updating MeseCraft (game)

Stop the server, update game files, and restart the server.

sudo service mesecraft-server stop
cd /opt/mesecraft-server/minetest/games/MeseCraft/
sudo git pull
sudo service mesecraft-server start

Updating Minetest (engine)

Stop the server, update engine files, recompile, and restart the server.

sudo service mesecraft-server stop
cd /opt/mesecraft-server/minetest/
sudo git pull
cd /opt/mesecraft-server/minetest/lib/irrlichtmt/
sudo git pull
cd /opt/mesecraft-server/minetest/
sudo cmake . -DRUN_IN_PLACE=TRUE -DBUILD_SERVER=TRUE -DBUILD_CLIENT=FALSE
sudo make install
sudo service mesecraft-server start

SECTION 4: Optional: Setting up Fail2Ban for Security

STEP 1: Install Fail2Ban.

Protect the server from unauthorized access attempts.

sudo apt install fail2ban

STEP 2: Configure Fail2Ban.

Create a custom filter and jail configuration for MeseCraft.

sudo nano /etc/fail2ban/filter.d/mesecraft-server.conf

Add:

# Fail2Ban configuration file for MeseCraft
[Definition]
failregex = ^: ACTION\[Server\]: Server: User \w+ at  supplied wrong password \(auth mechanism: SRP\)\.$
            ^: ACTION\[Server\]: Server: Player with the name "\w+" tried to connect from  but it was disallowed for the following reason: $

Create jail configuration:

sudo nano /etc/fail2ban/jail.local

Add:

[mesecraft-server]
enabled = true
port = 30000
filter = mesecraft-server
logpath = /opt/mesecraft-server/minetest/logs/minetest.log
maxretry = 3
bantime = 600
sudo systemctl restart fail2ban

SECTION 5: Optional: Setting up UFW Firewall

STEP 1: Install UFW.

Manage firewall rules easily.

sudo apt install ufw

STEP 2: Allow necessary ports.

Allow SSH and Minetest server ports.

sudo ufw allow 22/tcp
sudo ufw allow 30000/udp

STEP 3: Enable UFW.

sudo ufw enable

SECTION 6: Troubleshooting

Common Issues

If the server fails to start, check the log file for errors:

cat /opt/mesecraft-server/minetest/logs/minetest.log

Ensure all dependencies are installed and the configuration file is correct. Use sudo systemctl status mesecraft-server to get detailed error messages.

SECTION 7: Testing the Server

Verify the Server is Running

After starting the server, check if it is running:

sudo systemctl status mesecraft-server

SECTION 8: Additional Reading

Now that you’ve set up your own MeseCraft server, you can share it with the world! Let us know that you have a new server in the MeseCraft forum!

For more information: