How to run a Sons Of The Forest Server on Linux
April 7th 2024
Since, again, there is no other good guide™ on the internet I wrote one myself. If you want to run a SOTF server on docker there already is a Docker image. This guide is about setting up a SOTF server on a physical machine or VM without Docker.
However, here you go:
Prerequisites
- A Debian 12 machine/VM/whatever
- At least some knowledge about Linux/Debian, I will not describe every single command in detail
- Working port-forwarding on your Router if you want to connect to your server from the internet
Hardware recommendations
- 4 cores
- 8 GB RAM
- 10 GB Diskspace
Commands starting with a
#
are to be run as root/sudo. Commands starting with$
are to be run as theforest
-user:# run-as-root
$ run-as-forest
1. Install wine, steamcmd and xvfb
# apt update
# apt install software-properties-common
# apt-add-repository non-free
# dpkg --add-architecture i386
# apt update
# apt install steamcmd wine xvfb
2. Create a user
After that we need to create a dedicated user under which the SOTF server will be running:
# adduser forest
then login as that user:
# su - forest
3. Gameserver Setup
Commands in this section are to be executed under the
forest
user.
3.1 Installation via steamcmd
$ steamcmd +@sSteamCmdForcePlatformType windows
>login anonymous
>app_update 2465200 validate
>quit
3.2 Create a softlink
$ ln -s ~/.steam/steam/steamapps/common/Sons\ Of\ The\ Forest\ Dedicated\ Server/ ~/sotf
3.3 First start
The first start will most likely fail due to missing configuration, but nevertheless we need to start the server at least once for the config files to be created.
$ cd ~/sotf
$ xvfb-run --auto-servernum wine SonsOfTheForestDS.exe -userdatapath "config"
3.4 Edit the config files
~/sotf/config/ownerswhitelist.txt
Inside that file you have to add your Steam-ID. You can find that when logging into Steam, click on your Name at the top right and go to account details. On the left you will see your Steam ID.
$ nano ~/sotf/config/ownerswhitelist.txt
~/sotf/config/dedicatedserver.cfg
Here you want to change your port number, password, etc... Do this as you wish.
3.5 Second start
After configuring everything to your liking, you can start the server again and check if it starts up properly.
$ cd ~/sotf
$ xvfb-run --auto-servernum wine SonsOfTheForestDS.exe -userdatapath "config"
4. Autostarting
If you want the server to autostart I can give you 2 1 option:
4.1 cronjob / screen
First the dirty, rather easy solution: Starting a screen-session on startup via crontab.
So, first you need to install screen
:
# apt install screen
Then login as forest
and run crontab -e
. Here you need to add the following line:
@reboot screen -dmS sotf "cd ~/sotf && xvfb-run --auto-servernum wine SonsOfTheForestDS.exe -userdatapath "config" 2>&1 | tee ~/sotf/server.log"
This way the SOTF server will start automatically on reboot.
When running screen -R sotf
you will see the server's console. Use Ctrl+A+D
to get out of it or Ctrl+C
to stop the server.
5. Known issues
5.1 "UDP GamePort [8766] is closed. Please fix and restart."
When you see this error despite having setup port-forwarding correctly this is a bug. I have not found a solution to it yet, but at least there is a work-around:
$ nano ~/sotf/config/dedicatedserver.cfg
Set SkipNetworkAccessibilityTest
to true
.
This can also happen in the before mentioned docker-image, btw.