You could earn up to $300 by adding new articles!

Get Started Now

How to Setup a Minetest Server on Ubuntu 17.04

Published on: Fri, Dec 15, 2017 at 12:06 pm EST

Minetest is a free and open source alternative to the popular game Minecraft. The server is extremely easy to set up and run.

Prerequisites

  • A 1GB+ VPS or Dedicated instance running Ubuntu 17.04.
  • wget (installed with apt install wget).
  • A text editor.

Step 1: Adding the Minetest Stable repo and installing the server software

As Ubuntu tends to lag behind with packages for Minetest you'll be using the stable PPA instead. This can be added with the following commands.

# add-apt-repository ppa:minetestdevs/stable
# apt update

Following this you can install the server.

# apt install minetest

Step 2: Creating a user, opening ports, and testing the server

For security reasons it is always a good idea to run services within their own user as shown.

# useradd -mU minetest

This will create your minetest user with its own group and with a home directory for the server to run in.

Before testing you must open up port 30000 on Ubuntu's default firewall otherwise you'll be unable to connect.

# ufw allow 30000

Now would be a good time to test the server and see if it runs.

# su minetest
$ minetest

If all went well you'll be greeted by the following output:

WARNING[Main]: BanManager: creating /home/minetest/.minetest/worlds/world/ipban.txt
WARNING[Main]: NodeDefManager: Ignoring CONTENT_IGNORE redefinition
WARNING[Main]: /!\ You are using old player file backend. This backend is deprecated and will be removed in next release /!\
WARNING[Main]: Switching to SQLite3 or PostgreSQL is advised, please read http://wiki.minetest.net/Database_backends.
ACTION[Main]:         .__               __                   __   
ACTION[Main]:   _____ |__| ____   _____/  |_  ____   _______/  |_ 
ACTION[Main]:  /     \|  |/    \_/ __ \   __\/ __ \ /  ___/\   __\
ACTION[Main]: |  Y Y  \  |   |  \  ___/|  | \  ___/ \___ \  |  |  
ACTION[Main]: |__|_|  /__|___|  /\___  >__|  \___  >____  > |__|  
ACTION[Main]:       \/        \/     \/          \/     \/        
ACTION[Main]: World at [/home/minetest/.minetest/worlds/world]
ACTION[Main]: Server for gameid="minetest" listening on 0.0.0.0:30000.

If you receive the above warning about the player backend, don't worry too much as this will be fixed in the next step.

Connect to your server with your client to see if everything works. You can stop the server at any time by pressing Ctrl+C on your keyboard inside the shell.

Step 3: Configuring the Minetest server

First, you will want to download the example minetest.conf configuration file.

$ cd ~/.minetest
$ wget https://raw.githubusercontent.com/minetest/minetest/master/minetest.conf.example
$ mv minetest.conf.example minetest.conf

This file has an extensive list of possible settings for you to modify and enable (by uncommenting lines) however for the moment there are a few important ones you need to set.

The name and description of your server (for example):

server_name = Minetest server
server_description = Welcome to my Minetest Server

The IP address and desired port of your server (for example):

bind_address = 203.0.113.1
port = 30000

If you set a different port than the default 30000 make sure you update your firewall rules.

#ufw delete allow 30000
#ufw allow <port>

Another important option is name. Whoever connects to the Minetest server with the value specified will be given administrator privileges. Set this to a username you want and set a password for your account later.

You'll probably recall the warning about the player backend earlier so switching to SQLite3 is a must as the old backend is deprecated and will be removed in a later release, if it hasn't been already. If you didn't receive this message when you tested the server in step 2 then you can go straight to step 4.

$ minetest --server --migrate-players sqlite3 --world ~/.minetest/worlds/world

Afterwards you should see something like the following message.

ACTION[Main]: Successfully migrated 1 players
ACTION[Main]: world.mt updated

Step 4: Running the server on boot

In order to run the server on boot a systemd service file is needed. Thankfully these are fairly straightforward to create.

Exit back into your root shell and add the following to /etc/systemd/system/minetest.service

[Unit]
Description=Minetest Server
After=network.target

[Service]
Type=simple
User=minetest
Group=minetest
WorkingDirectory=/home/minetest
ExecStart=/usr/bin/minetest --server
Restart=on-abort

[Install]
WantedBy=multi-user.target

From now on the Minetest server can be started with systemctl (and will do so automatically after reboot or if the Minetest server crashes)

# systemctl enable minetest.service
# systemctl start minetest.service

Likewise you can check the status or stop/restart the Minetest server by replacing "start" in the above command.

Conclusion

Your Minetest server should be active and usable. If you have any issues connecting, verify that your port is open and IP address is correctly specified in minetest.conf. Information on managing player permissions and various server commands can be found on the Minetest wiki.

Want to contribute ?

You could earn up to $300 by adding new articles!

Get started in the SSD Cloud!