UGC bg

How to install a Valheim server with LGSM on Ubuntu 22.04 ?


Install a Valheim server with LGSM on Ubuntu 22.04

How to install a Valheim server with LGSM on Ubuntu 22.04

Valheim Title

In this tutorial, you will see how to install a Valheim game server, thanks to lgsm, on an Ubuntu 22.04 server, in a few minutes.

Valheim is a brutal exploration and survival game for 1-10 players, set in a procedurally-generated purgatory inspired by viking culture. Battle, build, and conquer your way to a saga worthy of Odin’s patronage!

lgsm is a command-line tool for quick, simple deployment and management of Linux dedicated game servers.

 

Prerequisites

Ubuntu 22.04 server

The first thing you will need is an Ubuntu 22.04 server.

For example, you can rent one very easily from OVHcloud:

User with sudo access

Once in possession of your server, connect to a user with sudo rights.

In our example, our server name is lgsm-host and the user is ubuntu.

Console

 

Install Dependencies

Steam and lgsm dependencies

Start by installing the necessary packages for lgsm and Steam.

as user ubuntu:

sudo dpkg --add-architecture i386 sudo apt update

apt update result

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 libc6-dev

When asked, accept licenses and service restart requests.

You can leave the selection as proposed and select OK directly.

apt update result

apt update result

apt update result

 

GameDig

GameDig is a recommended additional module that allows LinuxGSM to gather more info from the game server such as current map and connected players to be displayed in details and in logs. It also replaces the default LinuxGSM query module in monitor.

Install Node.js

GameDig requires Node.js, a JavaScript runtime environment installed to work.

Install Node.js with this command:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - sudo apt update && sudo apt install -y nodejs

When asked, select OK and press ENTER to continue:

reload services

Install GameDig

Then, install GameDig with this command:

sudo npm install gamedig -g

it is better to update the npm package as shown with the following command:

sudo npm install -g npm@8.9.0

 

Install lgsm

Our system is ready for lgsm installation.

Create a dedicated user

We will do this with a dedicated user: vhserver, which will not have sudo rights.

sudo adduser vhserver

Give the user a password and add informations if you want:

adduser vhserver

Now switch to the new created user:

su - vhserver

Install lgsm

The setup is done with this command:

wget -O linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh vhserver

install lgsm

 

Install Valheim server

Now ask to lgsm to install all necessary files to run a Valheim server:

./vhserver install

When asked, answer Y to questions.

install Valheim

install Valheim

After a few minutes, the installation is complete. The detail of the installation is accessible with this command:

./vhserver details

vhserver@lgsm-host:~$ ./vhserver details

Distro Details
==============================================================================================================
Date:      Tue May 10 08:13:32 UTC 2022
Distro:    Ubuntu 22.04 LTS
Arch:      x86_64
Kernel:    5.15.0-25-generic
Hostname:  lgsm-host
Uptime:    0d, 0h, 27m
tmux:      tmux 3.2a
glibc:     2.35

Server Resource
==============================================================================================================
CPU
Model:      Intel Core Processor (Broadwell, IBRS)
Cores:      2
Frequency:  2399.994MHz
Avg Load:   0.43, 0.26, 0.10

Memory
Mem:       total  used   free   cached  available
Physical:  6.7GB  212MB  6.2GB  2.4GB   6.2GB
Swap:      0B     0B     0B

Storage
Filesystem:  /dev/sda1
Total:                  49G
Used:                   3.4G
Available:   45G

Network
IP:           0.0.0.0
Internet IP:  162.19.69.3

Game Server Resource Usage
==============================================================================================================
CPU Used:  0%
Mem Used:  0%  0MB

Storage
Total:        1.4G
Serverfiles:  1.2G

Valheim Server Details
==============================================================================================================
Server name:      Valheim Server
App ID:           896660
Server IP:        0.0.0.0:2456
Internet IP:      162.19.69.3:2456
Server password:  NOT SET
Game world:       vhserver
Master server:    not listed
Status:           STOPPED

vhserver Script Details
==============================================================================================================
Script name:            vhserver
LinuxGSM version:       v21.5.1
glibc required:         2.15
Discord alert:          off
Email alert:            off
Gotify alert:           off
IFTTT alert:            off
Mailgun (email) alert:  off
Pushbullet alert:       off
Pushover alert:         off
Rocketchat alert:       off
Slack alert:            off
Telegram alert:         off
Update on start:        off
User:                   vhserver
Location:               /home/vhserver

Backups
==============================================================================================================
No Backups created

Command-line Parameters
==============================================================================================================
 ./valheim_server.x86_64 -name 'Valheim Server' -password  -port 2456 -world vhserver -public 1 -savedir '/home/vhserver/.config/unity3d/IronGate/Valheim'

Ports
==============================================================================================================
Change ports by editing the parameters in:
/home/vhserver/lgsm/config-lgsm/vhserver

Useful port diagnostic command:
ss -tuplwn | grep valheim_server.

DESCRIPTION  PORT  PROTOCOL  LISTEN
Game         2456  udp       0
Query        2457  udp       0

Status:	STOPPED

 

Configure your server

In the list of information, note the directory containing the configuration files: /home/vhserver/lgsm/config-lgsm/vhserver

By default, the parameters applied are those contained in the _default.cfg file.

In order to change the name of your server and protect it with a password, open this file and copy the lines referring to the servername and serverpassword variables. If you also want to change the port number, in this case also copy the line containing the port variable.

vi /home/vhserver/lgsm/config-lgsm/vhserver/_default.cfg

Open default configuration file

Now open the vhserver.cfg file in the same directory, add the lines corresponding to the parameters to be modified and change the values like this:

vi /home/vhserver/lgsm/config-lgsm/vhserver/vhserver.cfg

Open default configuration file

servername="My Awesome Valheim Server" # Minimum password length is 5. serverpassword="mypassword" port="2456"

 

Start the server

Everything is ready, start your server:

./vhserver start vhserver@lgsm-host:~$ ./vhserver start [ OK ] Starting vhserver: Applying steamclient.so sdk64 hardlink fix: Valheim [ OK ] Starting vhserver: Applying steamclient.so sdk32 link fix: Valheim [ OK ] Starting vhserver: My Awesome Valheim Server

Once started, check the status and detailed informations:

./vhserver details

vhserver@lgsm-host:~$ ./vhserver details

Distro Details
==============================================================================================================
Date:      Tue May 10 08:21:51 UTC 2022
Distro:    Ubuntu 22.04 LTS
Arch:      x86_64
Kernel:    5.15.0-25-generic
Hostname:  lgsm-host
Uptime:    0d, 0h, 35m
tmux:      tmux 3.2a
glibc:     2.35

Server Resource
==============================================================================================================
CPU
Model:      Intel Core Processor (Broadwell, IBRS)
Cores:      2
Frequency:  2399.994MHz
Avg Load:   0.67, 0.24, 0.12

Memory
Mem:       total  used   free   cached  available
Physical:  6.7GB  1.7GB  4.8GB  2.4GB   4.8GB
Swap:      0B     0B     0B

Storage
Filesystem:  /dev/sda1
Total:                  49G
Used:                   3.4G
Available:   45G

Network
IP:           0.0.0.0
Internet IP:  162.19.69.3

Game Server Resource Usage
==============================================================================================================
CPU Used:  111%
Mem Used:  22.2%  1506MB

Storage
Total:        1.4G
Serverfiles:  1.2G

Valheim Server Details
==============================================================================================================
Server name:      My Awesome Valheim Server
App ID:           896660
Server Version:   1.0.0.0
Server IP:        0.0.0.0:2456
Internet IP:      162.19.69.3:2456
Server password:  mypassword
Players:          0/64
Current map:      My Awesome Valheim Server
Game world:       vhserver
Master server:    listed
Status:           STARTED

vhserver Script Details
==============================================================================================================
Script name:            vhserver
LinuxGSM version:       v21.5.1
glibc required:         2.15
Discord alert:          off
Email alert:            off
Gotify alert:           off
IFTTT alert:            off
Mailgun (email) alert:  off
Pushbullet alert:       off
Pushover alert:         off
Rocketchat alert:       off
Slack alert:            off
Telegram alert:         off
Update on start:        off
User:                   vhserver
Location:               /home/vhserver

Backups
==============================================================================================================
No Backups created

Command-line Parameters
==============================================================================================================
 ./valheim_server.x86_64 -name 'My Awesome Valheim Server' -password mypassword -port 2456 -world vhserver -public 1 -savedir '/home/vhserver/.config/unity3d/IronGate/Valheim'

Ports
==============================================================================================================
Change ports by editing the parameters in:
/home/vhserver/lgsm/config-lgsm/vhserver

Useful port diagnostic command:
ss -tuplwn | grep valheim_server.

DESCRIPTION  PORT  PROTOCOL  LISTEN
Game         2456  udp       1
Query        2457  udp       1

Status:	STARTED

 

Schedule your admin tasks

Whith lgsm, you can simply use crontab to schedule your maintenance or admin tasks.

For example:

crontab -e */5 * * * * /home/vhserver/vhserver monitor > /dev/null 2>&1 */30 * * * * /home/vhserver/vhserver update > /dev/null 2>&1 0 0 * * 0 /home/vhserver/vhserver update-lgsm > /dev/null 2>&1

 

Connect to your server and play!

To connect to the server, open your Valheim game, and join the server either by searching with name, or by joining with IP address.

join server

And now it’s up to you to conquer Odin’s kingdom!

let's play