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

From Minetest Wiki
Jump to navigation Jump to search
(Various syntax and wording enhancements.)
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.
+
These instructions have been tested in Debian Jessie (“Testing” as of January 2015) which includes a <code>minetest-server</code> package.
  
 
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.
 
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.
Line 6: Line 6:
  
 
== Installation and initial preparation ==
 
== Installation and initial preparation ==
 +
 +
''Commands prefixed with '''$''' are to be run with limited privileges, whereas commands prefixed with '''#''' should be used with administrator privileges (usually using <code>sudo</code>).''
  
 
=== Preparing a Debian 7 virtual machine (optional) ===
 
=== Preparing a Debian 7 virtual machine (optional) ===
 +
 
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.
 
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.
  
Line 18: Line 21:
 
Once installed, you can access the console via VNC.
 
Once installed, you can access the console via VNC.
  
== Installing the minetest server application ==  
+
== Installing the Minetest server program ==  
 +
 
 
Install the <code>minetest-server</code> package:
 
Install the <code>minetest-server</code> package:
<pre># apt-get install minetest-server</pre>
+
 
 +
# apt-get install minetest-server
  
 
The current Debian package in Jessie 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:
 
The current Debian package in Jessie 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:
<pre># adduser minetest</pre>
+
 
 +
# adduser minetest
  
 
Since version 0.4.10+repack-3 a manual configuration of Debian's minetest-server package is no longer required. Please check out the section about systemd and sysV-init below.
 
Since version 0.4.10+repack-3 a manual configuration of Debian's minetest-server package is no longer required. Please check out the section about systemd and sysV-init below.
Line 32: Line 38:
  
 
The server can be started manually by invoking its command:
 
The server can be started manually by invoking its command:
<pre>$ /usr/games/minetestserver --info</pre>
+
 
 +
$ minetestserver --info
  
 
The last few lines of terminal output should be similar to this:
 
The last few lines of terminal output should be similar to this:
  
<pre>
+
03:33:25: INFO[main]: Server: Loading environment metadata
03:33:25: INFO[main]: Server: Loading environment metadata
+
03:33:25: INFO[main]: Server: Loading players
03:33:25: INFO[main]: Server: Loading players
+
03:33:25: INFO[main]: Starting server on port 30000...
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]:  _____ |__| ____  _____/  |_  ____  _______/  |_  
+
03:33:25: ACTION[main]:  /    \|  |/    \_/ __ \  __\/ __ \ /  ___/\  __\
03:33:25: ACTION[main]:  /    \|  |/    \_/ __ \  __\/ __ \ /  ___/\  __\
+
03:33:25: ACTION[main]: |  Y Y  \  |  |  \  ___/|  | \  ___/ \___ \  |  |   
03:33:25: ACTION[main]: |  Y Y  \  |  |  \  ___/|  | \  ___/ \___ \  |  |   
+
03:33:25: ACTION[main]: |__|_|  /__|___|  /\___  >__|  \___  >____  > |__|   
03:33:25: ACTION[main]: |__|_|  /__|___|  /\___  >__|  \___  >____  > |__|   
+
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]: World at [/home/minetest/.minetest/worlds/world]
+
03:33:25: ACTION[main]: Server for gameid="minetest" listening on port 30000.
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:25: INFO[ServerThread]: Server creating detached inventory "creative"
+
03:33:28: INFO[ServerThread]: ServerMap: SQLite3 database opened
03:33:28: INFO[ServerThread]: ServerMap: SQLite3 database opened</pre>
 
  
 
== Manually stopping the server ==
 
== Manually stopping the server ==
Line 57: Line 63:
 
The last few lines of terminal output should be similar to this:
 
The last few lines of terminal output should be similar to this:
  
<pre>^C03:34:52: INFO: sigint_handler(): Ctrl-C pressed, shutting down.
+
03:34:52: INFO: sigint_handler(): Ctrl-C pressed, shutting down.
03:34:52: INFO[main]: Dedicated server quitting
+
03:34:52: INFO[main]: Dedicated server quitting
03:34:52: INFO[main]: Server destructing
+
03:34:52: INFO[main]: Server destructing
03:34:52: INFO[main]: Server: Saving players
+
03:34:52: INFO[main]: Server: Saving players
03:34:52: INFO[main]: Server: Saving environment metadata
+
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: Stopping and waiting threads
03:34:52: INFO[main]: Server: Threads stopped
+
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]: ServerMap: Saved map to /home/minetest/.minetest/worlds/world
03:34:52: INFO[main]: RollbackManager::~RollbackManager()
+
03:34:52: INFO[main]: RollbackManager::~RollbackManager()
03:34:52: INFO[main]: RollbackManager::flush()
+
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]: BanManager: saving to /home/minetest/.minetest/worlds/world/ipban.txt
03:34:52: INFO[main]: Server: Deinitializing scripting</pre>
+
03:34:52: INFO[main]: Server: Deinitializing scripting
  
 
== Setup automatic startup at boot ==
 
== Setup automatic startup at boot ==
Line 81: Line 87:
 
# Save the file (Ctrl-X if using the <code>nano</code> editor)
 
# Save the file (Ctrl-X if using the <code>nano</code> editor)
  
== Running the minetest server as a systemd service or sysV-init daemon ==
+
== Running the Minetest server as a systemd service or sysV-init daemon ==
  
 
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''.
 
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''.
Line 89: Line 95:
 
Start the server with
 
Start the server with
  
<pre>systemctl start minetest-server</pre>
+
# systemctl start minetest-server
  
 
Stop the server with
 
Stop the server with
  
<pre>systemctl stop minetest-server</pre>
+
# systemctl stop minetest-server
  
 
You can disable the server on boot with
 
You can disable the server on boot with
  
<pre>systemctl disable minetest-server</pre>
+
# systemctl disable minetest-server
  
 
You can start multiple servers with different configurations by using systemd's template unit feature.
 
You can start multiple servers with different configurations by using systemd's template unit feature.
  
<pre>systemctl start minetest-server@pvp.service</pre>
+
# 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.
+
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 '''pvp''' after @ with your desired name.
+
Simply replace <code>pvp</code> after @ with your desired name.
  
 
=== sysV-init ===
 
=== sysV-init ===
Line 110: Line 116:
 
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.
 
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.
  
<pre>service minetest-server start</pre>
+
# service minetest-server start
or
+
 
<pre>service minetest-server stop</pre>
+
or:
 +
 
 +
#service minetest-server stop
  
 
=== Further information ===
 
=== Further information ===
  
 
* For a detailed explanation of the server configuration file, see the [https://github.com/minetest/minetest/blob/master/minetest.conf.example minetest.conf] page.
 
* For a detailed explanation of the server configuration file, see the [https://github.com/minetest/minetest/blob/master/minetest.conf.example minetest.conf] page.
 
 
* You may also want to consider to use a different [[Database backends|database backend]] for your world.
 
* You may also want to consider to use a different [[Database backends|database backend]] for your world.
 
 
* See the [[Server commands]] page for a list of useful commands.
 
* See the [[Server commands]] page for a list of useful commands.
 
 
* Also see [[Itemstrings|Item strings]] for the itemstrings for use with the <code>/give</code> and <code>/giveme</code> commands.
 
* Also see [[Itemstrings|Item strings]] for the itemstrings for use with the <code>/give</code> and <code>/giveme</code> commands.
 
 
* See the [[Privileges]] page for detailed information on the privilege system.
 
* See the [[Privileges]] page for detailed information on the privilege system.
 +
* You may want to study this [https://forum.minetest.net/viewtopic.php?f=3&t=3837 One-line script for installing/compiling Minetest Git, for Debian / Ubuntu / Mint]
  
* 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]
+
== A few tips ==
  
== A few tips ==
+
* The <code>.minetest</code> directory contains game data (<code>worlds, config, debug.txt</code>).
 +
* 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.
  
* The <code>.minetest</code> directory contains game data (worlds, config, debug.txt)
+
minetest/
* 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.
+
├── bin/
<pre>
+
├── builtin/
minetest/
+
├── cache/
├── bin/
+
│  ├── media/
├── builtin/
+
│  └── tmp/
├── cache/
+
├── client/
│  ├── media/
+
│  ├── serverlist/
│  └── tmp/
+
│  └── shaders/
├── client/
+
│      ├──
│  ├── serverlist/
+
├── doc/
│  └── shaders/
+
├── fonts/
│      ├── alpha_shader/
+
├── games/
│      ├── leaves_shader/
+
│  ├── minetest_game/
│      ├── liquids_shader/
+
│  ├── minimal/
│      ├── plants_shader/
+
│  └── (installed extra games)
│      └── solids_shader/
+
├── locale/ (lots of language folders)
├── doc/
+
├── mods/
├── fonts/
+
│  └── (installed extra mods and modpacks)
├── games/
+
├── textures/
│  ├── minetest_game/
+
│  ├── base/
│  ├── minimal/
+
│  │  └── pack/
│  └── ... (installed extra games)
+
│  └── (installed extra texturepacks)
├── locale/ (lots of language folders)
+
└── worlds/
├── mods/
+
    └── (saved worlds. Some with exclusive world 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]]

Revision as of 17:54, 2 January 2015

These instructions have been tested in Debian Jessie (“Testing” as of January 2015) which includes a minetest-server package.

A simple Minetest server can be started in any Debian (or derivative distribution, like Ubuntu or Linux Mint) 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.

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

Installation and initial preparation

Commands prefixed with $ are to be run with limited privileges, whereas commands prefixed with # should be used with administrator privileges (usually using sudo).

Preparing a Debian 7 virtual machine (optional)

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 following command will prepare a virtual machine named "dungeon" in an existing KVM host:

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

Once installed, you can access the console via VNC.

Installing the Minetest server program

Install the minetest-server package:

# apt-get install minetest-server

The current Debian package in Jessie does not automatically setup the Minetest server to start as a service. It can run under the root user but it may be preferrable to create a user to run it:

# adduser minetest

Since version 0.4.10+repack-3 a manual configuration of Debian's minetest-server package is no longer required. Please check out the section about systemd and sysV-init below.

Before setting up automatic startup at boot, consider manually running the server to determine the best command line arguments.

Manually starting the server

The server can be started manually by invoking its command:

$ minetestserver --info

The last few lines of terminal output should be similar to this:

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

Manually stopping the server

To stop the server, press Ctrl + C. Avoid killing it unless necessary, since that may cause world corruption.

The last few lines of terminal output should be similar to this:

03:34:52: INFO: sigint_handler(): Ctrl-C pressed, shutting down.
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

Setup automatic startup at boot

With a boot-time scheduled command

Once you're satisfied with command line arguments and having tested the server works, you can setup automatic startup at boot:

  1. Login as the user previously created. This can be a non-privileged user.
  2. Add the minetestserver command as determined after testing with manual server startup to crontab
    1. Invoke the crontab editor:
      $ crontab -e
    2. Add your command to be executed at reboot to the very end of the file, for example:
      @reboot /usr/games/minetestserver --info --worldname MyWorld
  3. Save the file (Ctrl-X if using the nano editor)

Running the Minetest server as a systemd service or sysV-init daemon

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.

systemd

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

Further information

A few tips

  • The .minetest directory contains game data (worlds, config, debug.txt).
  • 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.
minetest/
├── bin/
├── builtin/
├── cache/
│   ├── media/
│   └── tmp/
├── client/
│   ├── serverlist/
│   └── shaders/
│       ├── …
├── 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)