Difference between revisions of "Setting up a server/Debian"

From Minetest Wiki
Jump to navigation Jump to search
(clarify Luanti name more)
 
(12 intermediate revisions by 7 users not shown)
Line 1: Line 1:
These instructions have been tested in Debian Jessie (“Testing” as of May 2014) which includes a <code>minetest-server</code> package.
+
{{Languages}}
 +
A simple Luanti/Minetest [[server]] can be started in any Debian (Ubuntu, Linux Mint or derivative distribution) that has the <code>minetest</code> package by going to its “Server” tab, however such a game only remains available for the duration of the host's playing session.
  
A simple Minetest [[server]] can be started in any Debian (or derivative distribution, like Ubuntu or Linux Mint) that has the <code>minetest</code> package by going to its “Server” tab, however such a game only remains available for the duration of the host's playing session.
+
''Note: Luanti is called “Minetest” for the rest of this page due to old package versions, where it’s still called “Minetest”.''
  
 
This guide is aimed at providing a more permanent, minimal server environment setup without a graphical desktop environment.
 
This guide is aimed at providing a more permanent, minimal server environment setup without a graphical desktop environment.
  
== Installation and initial preparation ==
+
== Installing Minetest version 5 from Buster Backports ==
  
=== Preparing a Debian 7 virtual machine (optional) ===
+
As of August 2019, minetest is available in version 0.4.17 in Debian Buster (Stable), and also in version 5.0.1 in Buster Backports.
If you wish to install Minetest in its own dedicated environment, it's an interesting option to do so on a KVM host, as a dedicated virtual machine.
 
  
This requires previous installation and configuration of KVM and the '''virtinst''' package on your host system. You can also configure a network bridge so your LAN will have direct access to the server on the same subnet.
+
The two versions are not compatible, and installing both version on the same system would be tricky. Since most servers probably use the newest versions, and players too, the version from the backports comes as a natural choice.
  
The following command will prepare a virtual machine named "dungeon" in an existing KVM host:
+
First, add the [https://wiki.debian.org/Backports Backrpots repositories as explained on Debian Wiki].
  
sudo virt-install -n dungeon -r 1024 --disk path=/var/lib/libvirt/images/dungeon.img,bus=virtio,size=10 -l http://ftp.ca.debian.org/debian/dists/wheezy/main/installer-i386/ --accelerate -b br0,model=virtio --connect=qemu:///system --vnc --noautoconsole -v
+
Then install the minetest packages you need from it.
  
Once installed, you can access the console via VNC.
+
# apt install -t buster-backports minetest-server
  
== Installing the minetest server application ==  
+
== Manage the server startup ==
Install the <code>minetest-server</code> package:
 
<pre># apt-get install minetest-server</pre>
 
  
The current Debian package does not automatically setup the Minetest server to start as a service. It can run under the <code>root</code> user but it may be preferrable to create a user to run it:
+
Systemd is the default and currently prefered solution to manage services on Debian.
<pre># adduser minetest</pre>
 
  
Before setting up automatic startup at boot, consider manually running the server to determine the best command line arguments.
+
=== systemd ===
  
== Manually starting the server ==
+
Since version 0.4.10+repack-3 the Debian minetest-server package automatically creates a system-wide, unprivileged user called '''Debian-minetest'''. The home directory of this user is ''/var/games/minetest-server''. You can do all the configuration in ''/etc/minetest/minetest.conf''. All log files are written to ''/var/log/minetest''.
  
The server can be started manually by invoking its command:
+
It should already be started. Check whether its running (or why it doesn't start) with
<pre>$ /usr/games/minetestserver --info</pre>
 
  
The last few lines of terminal output should be similar to this:
+
# systemctl status minetest-server
  
<pre>
+
Start the server with
03:33:25: INFO[main]: Server: Loading environment metadata
 
03:33:25: INFO[main]: Server: Loading players
 
03:33:25: INFO[main]: Starting server on port 30000...
 
03:33:25: ACTION[main]:        .__              __                  __ 
 
03:33:25: ACTION[main]:  _____ |__| ____  _____/  |_  ____  _______/  |_
 
03:33:25: ACTION[main]:  /    \|  |/    \_/ __ \  __\/ __ \ /  ___/\  __\
 
03:33:25: ACTION[main]: |  Y Y  \  |  |  \  ___/|  | \  ___/ \___ \  |  | 
 
03:33:25: ACTION[main]: |__|_|  /__|___|  /\___  >__|  \___  >____  > |__| 
 
03:33:25: ACTION[main]:      \/        \/    \/          \/    \/       
 
03:33:25: ACTION[main]: World at [/home/minetest/.minetest/worlds/world]
 
03:33:25: ACTION[main]: Server for gameid="minetest" listening on port 30000.
 
03:33:25: INFO[ServerThread]: Server creating detached inventory "creative"
 
03:33:28: INFO[ServerThread]: ServerMap: SQLite3 database opened</pre>
 
  
== Manually stopping the server ==
+
# systemctl start minetest-server
  
To stop the server, press <kbd>Ctrl + C</kbd>. '''Avoid killing it''' unless necessary, since that may cause world corruption.
+
Stop the server with
  
The last few lines of terminal output should be similar to this:
+
# systemctl stop minetest-server
  
<pre>^C03:34:52: INFO: sigint_handler(): Ctrl-C pressed, shutting down.
+
You can disable the server on boot with
03:34:52: INFO[main]: Dedicated server quitting
 
03:34:52: INFO[main]: Server destructing
 
03:34:52: INFO[main]: Server: Saving players
 
03:34:52: INFO[main]: Server: Saving environment metadata
 
03:34:52: INFO[main]: Server: Stopping and waiting threads
 
03:34:52: INFO[main]: Server: Threads stopped
 
03:34:52: INFO[main]: ServerMap: Saved map to /home/minetest/.minetest/worlds/world
 
03:34:52: INFO[main]: RollbackManager::~RollbackManager()
 
03:34:52: INFO[main]: RollbackManager::flush()
 
03:34:52: INFO[main]: BanManager: saving to /home/minetest/.minetest/worlds/world/ipban.txt
 
03:34:52: INFO[main]: Server: Deinitializing scripting</pre>
 
  
== Setup automatic startup at boot ==
+
# systemctl disable minetest-server
  
=== With a boot-time scheduled command ===
+
You can start multiple servers with different configurations by using systemd's template unit feature.
  
Once you're satisfied with command line arguments and having tested the server works, you can setup automatic startup at boot:
+
# systemctl start minetest-server@pvp.service
# Login as the user previously created. This can be a non-privileged user.
 
# Add the <code>minetestserver</code> command as determined after testing with manual server startup to <code>crontab</code>
 
## Invoke the <code>crontab</code> editor: <pre>$ crontab -e</pre>
 
## Add your command to be executed at reboot to the very end of the file, for example: <pre>@reboot /usr/games/minetestserver --info --worldname MyWorld</pre>
 
# Save the file (Ctrl-X if using the <code>nano</code> editor)
 
  
=== With an init script ===
+
Provided that you also saved the configuration file for this server in <code>/etc/minetest/pvp.conf</code>, the server will now use this second configuration and log everything to <code>/var/log/minetest/pvp.log</code>.
 +
Simply replace <code>pvp</code> after @ with your desired name.
  
A better practice when running a service in Debian is to create a proper init script and configuration for it.
+
=== sysV-init ===
  
Check [https://forum.minetest.net/viewtopic.php?p=135918#p135918 this forum discussion] for details, a cleaned-up version is being worked on.
+
If systemd is not your default init system and you still prefer to use the old sysV-init style configuration, you can use the service command to start or stop your server.
  
=== Further information ===
+
# service minetest-server start
  
* For a detailed explanation of the server configuration file, see the [https://github.com/minetest/minetest/blob/master/minetest.conf.example minetest.conf] page.
+
or:
  
* You may also want to consider to use a different [[Database backends|database backend]] for your world.
+
# service minetest-server stop
  
* See the [[Server commands]] page for a list of useful commands.
+
== Configuration of the server ==
  
* Also see [[Itemstrings|Item strings]] for the itemstrings for use with the <code>/give</code> and <code>/giveme</code> commands.
+
You can find a commented server configuration file on /usr/share/doc/minetest/minetest.conf.example.gz.
  
* See the [[Privileges]] page for detailed information on the privilege system.
+
  # zcat /usr/share/doc/minetest/minetest.conf.example.gz > /etc/minetest/myservername.conf
 +
 
 +
Interesting parameters start with the Server / Singleplayer section, you may delete client parameters prior to that.
 +
 
 +
== Install and enable mods ==
 +
 
 +
=== Install a mod ===
 +
 
 +
You can install the packages you want from the available mods.
 +
 
 +
If you need to install mods which aren't packaged yet in Debian (for instance, mobs_animal and mobs_monster), you can add them in the /var/games/minetest-server/.minetest/mods directory (create it if needed).
 +
 
 +
=== Enable a mod ===
 +
 
 +
You will need to enable them afterwards. Mod activation is not a general server setup, but a world setup.
 +
 
 +
Once a server is started, it should create world files, and refresh them to add configuration lines with the available mods in the world.mt file.
 +
 
 +
  $ cat /var/games/minetest-server/.minetest/worlds/world/world.mt
 +
  creative_mode = false
 +
  auth_backend = sqlite3
 +
  player_backend = sqlite3
 +
  gameid = minetest
 +
  enable_damage = true
 +
  backend = sqlite3
 +
  load_mod_mobs_animal = true
 +
  load_mod_mobs = true
 +
  load_mod_mobs_monster = false
  
* You may want to study this [https://forum.minetest.net/viewtopic.php?f=3&t=3837 One-line script for installing/compiling Minetest git, Debian/Ubuntu/Mint]
+
First, stop the server running the world. Then edit this file to enable the mod, just change the value from false to true on the corresponding load_mod_* lines.  
  
== A few tips ==
+
== Further information ==
  
* The <code>.minetest</code> directory contains game data (worlds, config, debug.txt)
+
* For a detailed explanation of the server configuration file, see the [http://github.com/minetest/minetest/blob/master/minetest.conf.example minetest.conf] page.
* File structure with the folders Minetest adds after some usage as client and server, as well as the positions (...) that costum made content goes could look like this.
+
* Use a different [[Database backends|database backend]] for your world.
<pre>
+
* [http://forum.minetest.net/viewtopic.php?f=3&t=3837 One-line script for installing/compiling Minetest Git, for Debian / Ubuntu / Mint]
minetest/
+
* [https://wiki.debian.org/Games/Minetest Debian Wiki Minetest page]
├── bin/
+
* [http://forum.minetest.net/viewtopic.php?f=10&t=9588 Guide to create fast minetest server on Debian]
├── builtin/
+
* [[Server commands]] page for a list of useful commands.
├── cache/
+
* [[Itemstrings|Item strings]] for the itemstrings for use with the <code>/give</code> and <code>/giveme</code> commands.
│  ├── media/
+
* See the [[Privileges]] page for detailed information on the privilege system.
│  └── tmp/
 
├── client/
 
│  ├── serverlist/
 
│  └── shaders/
 
│      ├── alpha_shader/
 
│      ├── leaves_shader/
 
│      ├── liquids_shader/
 
│      ├── plants_shader/
 
│      └── solids_shader/
 
├── doc/
 
├── fonts/
 
├── games/
 
│  ├── minetest_game/
 
│  ├── minimal/
 
│  └── ... (installed extra games)
 
├── locale/ (lots of language folders)
 
├── mods/
 
│  └── ... (installed extra mods and modpacks)
 
├── textures/
 
│  ├── base/
 
│  │  └── pack/
 
│  └── ... (installed extra texturepacks)
 
└── worlds/
 
    └── ... (saved worlds. Some with exclusive world mods)
 
</pre>
 
  
  
 
[[Category:Server]]
 
[[Category:Server]]
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]

Latest revision as of 19:09, 27 October 2024

Languages Language: English • Deutsch • 日本語

A simple Luanti/Minetest server can be started in any Debian (Ubuntu, Linux Mint or derivative distribution) that has the minetest package by going to its “Server” tab, however such a game only remains available for the duration of the host's playing session.

Note: Luanti is called “Minetest” for the rest of this page due to old package versions, where it’s still called “Minetest”.

This guide is aimed at providing a more permanent, minimal server environment setup without a graphical desktop environment.

Installing Minetest version 5 from Buster Backports

As of August 2019, minetest is available in version 0.4.17 in Debian Buster (Stable), and also in version 5.0.1 in Buster Backports.

The two versions are not compatible, and installing both version on the same system would be tricky. Since most servers probably use the newest versions, and players too, the version from the backports comes as a natural choice.

First, add the Backrpots repositories as explained on Debian Wiki.

Then install the minetest packages you need from it.

# apt install -t buster-backports minetest-server

Manage the server startup

Systemd is the default and currently prefered solution to manage services on Debian.

systemd

Since version 0.4.10+repack-3 the Debian minetest-server package automatically creates a system-wide, unprivileged user called Debian-minetest. The home directory of this user is /var/games/minetest-server. You can do all the configuration in /etc/minetest/minetest.conf. All log files are written to /var/log/minetest.

It should already be started. Check whether its running (or why it doesn't start) with

# systemctl status minetest-server

Start the server with

# systemctl start minetest-server

Stop the server with

# systemctl stop minetest-server

You can disable the server on boot with

# systemctl disable minetest-server

You can start multiple servers with different configurations by using systemd's template unit feature.

# systemctl start minetest-server@pvp.service

Provided that you also saved the configuration file for this server in /etc/minetest/pvp.conf, the server will now use this second configuration and log everything to /var/log/minetest/pvp.log. Simply replace pvp after @ with your desired name.

sysV-init

If systemd is not your default init system and you still prefer to use the old sysV-init style configuration, you can use the service command to start or stop your server.

# service minetest-server start

or:

# service minetest-server stop

Configuration of the server

You can find a commented server configuration file on /usr/share/doc/minetest/minetest.conf.example.gz.

 # zcat /usr/share/doc/minetest/minetest.conf.example.gz > /etc/minetest/myservername.conf

Interesting parameters start with the Server / Singleplayer section, you may delete client parameters prior to that.

Install and enable mods

Install a mod

You can install the packages you want from the available mods.

If you need to install mods which aren't packaged yet in Debian (for instance, mobs_animal and mobs_monster), you can add them in the /var/games/minetest-server/.minetest/mods directory (create it if needed).

Enable a mod

You will need to enable them afterwards. Mod activation is not a general server setup, but a world setup.

Once a server is started, it should create world files, and refresh them to add configuration lines with the available mods in the world.mt file.

 $ cat /var/games/minetest-server/.minetest/worlds/world/world.mt
 creative_mode = false
 auth_backend = sqlite3
 player_backend = sqlite3
 gameid = minetest
 enable_damage = true
 backend = sqlite3
 load_mod_mobs_animal = true
 load_mod_mobs = true
 load_mod_mobs_monster = false

First, stop the server running the world. Then edit this file to enable the mod, just change the value from false to true on the corresponding load_mod_* lines.

Further information