Valheim Server Setup

LGSM Setup

Dependencies

Ubuntu 20.04
sudo dpkg --add-architecture i386; sudo apt update; sudo apt install curl wget file tar bzip2 gzip unzip bsdmainutils python3 util-linux ca-certificates binutils bc jq tmux netcat lib32gcc1 lib32stdc++6 libsdl2-2.0-0:i386 steamcmd
Ubuntu 20.10 or higher
sudo dpkg --add-architecture i386; sudo apt update; sudo apt install curl wget file tar bzip2 gzip unzip bsdmainutils python3 util-linux ca-certificates binutils bc jq tmux netcat lib32gcc-s1 lib32stdc++6 libsdl2-2.0-0:i386 steamcmd

If the account running the server has sudo rights it will install dependencies automatically This can be done with usermod -aG sudo username

Installation

  • Create a new user, in this example we will use vhserver
adduser vhserver
  • Switch to the new user:
su - vhserver
  • Download the lgsm script
wget -O linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh vhserver
  • Run the installer:
./vhserver install

Systemd

  • Run the following command to add a new systemd unit:
sudo nano /etc/systemd/system/vhserver.service

Copy the following text into the editor:

[Unit]
Description=LinuxGSM Valheim Server
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
User=vhserver
WorkingDirectory=/home/vhserver
RemainAfterExit=yes   #Assume that the service is running after main process exits with code 0
ExecStart=/home/vhserver/vhserver start
ExecStop=/home/vhserver/vhserver stop
Restart=no

[Install]
WantedBy=multi-user.target
  • Save and exit the editor
  • Enable the service
sudo systemctl enable vhserver

Do not start the service yet

Configure the lgsm instance

  • If not already, switch to the vhserver user and navigate to the config folder:
su - vhserver
cd /home/vhserver/lgsm/config-lgsm/vhserver

https://www.reddit.com/r/valheim/comments/lyvfb1/guide_how_to_add_bepinex_add_discord_integration/