Linux Game Servers
A quick guide on installing various game servers on Debian. As I write more guides for installing different game servers, this page may be split up into multiple pages.
Create a user account
Before creating any game servers, we will need to first create a new user account to run the game servers as. We will also enable user lingering with loginctl, to ensure that the systemd services created will always remain running.
- Create a new user account
useradd -m -s /bin/bash games
- Enable user lingering for the games user
loginctl enable-linger games
Minecraft Server
- Install Java JRE Headless
apt install default-jre-headless
- Create a new directory for the Minecraft server
su games -
mkdir -p ~/games/minecraft
cd ~/games/minecraft
-
Download latest Minecraft server .jar file from https://www.minecraft.net/en-us/download/server, and save it to the
~/games/minecraft
directory. -
Make systemd service directory (as minecraft user) and make a new service file:
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/minecraft.service
Contents of file ~/.config/systemd/user/minecraft.service
:
[Unit]
Description=Minecraft Server
[Service]
WorkingDirectory=%h/games/minecraft
ExecStart=java -Xms1G -Xmx2G -jar server.jar
[Install]
WantedBy=default.target
- Start and enable service
systemctl --user daemon-reload
systemctl --user start minecraft
systemctl --user enable minecraft
- Open port 25565/tcp in firewall to allow others to connect to the server
firewall-cmd --permanent --zone=public --add-port=25565/tcp
- Launch Minecraft on your computer and connect to the server
BeamMP Server
- Install BeamMP dependencies and dtach
apt install liblua5.3-0 libssl3 curl dtach
- Create game server folder
mkdir -p ~/games/beammp
cd ~/games/beammp
- Download BeamMP from GitHub.
Note: At the time of writing, there is no Debian 12 binary. Instead, use the Ubuntu 22.04 binary which appears to work fine.
wget https://github.com/BeamMP/BeamMP-Server/releases/download/v3.1.1/BeamMP-Server-ubuntu-22.04 -O beammp-server
# make the binary executable
chmod +x beammp-server
-
Configure BeamMP using the directions on the BeamMP Wiki.
-
Create systemd service file at
~/.config/systemd/user/beammp.service
. Contents are below.
[Unit]
Description=BeamMP Server
[Service]
Type=forking
Restart=on-failure
RestartSec=5
WorkingDirectory=%h/games/beammp/
ExecStart=dtach -n /tmp/beammp ./beammp-server
[Install]
WantedBy=default.target
Start and optionally enable service
systemctl --user daemon-reload
systemctl --user start beammp
systemctl --user enable beammp
- Open port UDP and TCP port 30814, the port the BeamMP server listens on
firewall-cmd --permanent --zone=public --add-port=30814/tcp --add-port=30814/udp
If you need to use the BeamMP server console, run the following command:
dtach -a /tmp/beammp
You can detach from BeamMP console by hitting Ctrl + \. If you accidentally kill the server, it will automatically restart in 5 seconds.