7

Guide for creating a dedicated valheim server on debian

 2 years ago
source link: https://gist.github.com/mmercedes/64428eac49d970d6bcac99718a0066a3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

recommened you do this from within tmux since the steamcmd utility creates its own repl

Install SteamCMD

taken from here

$ sudo useradd -m steam
$ sudo apt update && sudo apt-get install lib32gcc1 -y
$ sudo su - steam
$ mkdir ~/Steam && cd ~/Steam
$ curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
$ ./steamcmd.sh

The last command should bring you into a steam client repl. From here you can login with your steam account (only required once) so Valheim can downloaded.

Steam> login <steam_username>
# this will prompt for password and two-factor auth
Steam> exit

Install Valheim server

Download Valheim from steam into steam user's homedir

$ mkdir ~/Valheim
$ ./steamcmd.sh +login <steam_username> +force_install_dir /home/steam/Valheim +app_update 896660 validate +exit

Now to make a copy of the server start script and create a systemctl service for it so can be auto ran on boot

cp ~/Valheim/start_server.sh ~/Valheim/start_server_local_copy.sh
nano ~/Valheim/start_server_local_copy.sh

Add this line to the local copy of the server start script so that it authenticates via your steam account prior to launching. Should go right after the echo "Starting server... line and fill in the value for your steam username

/home/steam/Steam/steamcmd.sh +login <steam_username> +force_install_dir /home/steam/Valheim +app_update 896660 +quit

Next edit the values for -name -world and -password in the line that looks like this:

./valheim_server.x86_64 -name "My server" -port 2456 -world "Dedicated" -password "secret"

Save the file and exit nano

Create and start systemd service

touch ~/valheim.service
nano ~/valheim.service

In Nano, paste and save the following

[Unit]
Description=Valheim service
Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
Restart=on-failure
RestartSec=10
User=steam
WorkingDirectory=/home/steam/Valheim
ExecStart=/bin/bash /home/steam/Valheim/start_server_local_copy.sh

[Install]
WantedBy=multi-user.target

Now to actually create/start the systemd service, switch back to a user with root access as the steam user will not

sudo cp /home/steam/valheim.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl start valheim

after a few seconds, you can check the status of the server process with

sudo systemctl status valheim

once its looks good, enable the service to run automatically at boot

sudo systemctl enable valheim

Enable port forwarding

Out of the scope of this as its highly dependent on your setup, but you will need to open port 2456 for public traffic before users will be able to connect to your server remotely

Copying worlds

you can simply copy/replace the entire worlds folder if you want to transfer your current world to the new server

Windows location:

C:\Users\snipe\AppData\LocalLow\IronGate\Valheim\worlds

Linux location:

~/.config/unity3d/IronGate/Valheim/worlds

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK