Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Valheim Dedicated Game Server Setup Guides
- **LINUX USERS SEE BOTTOM OF FILE
- ---------------------------------------------------------
- source :
- https://steamcommunity.com/sharedfiles/filedetails/?id=2383801614
- This guide shows you what is required to get your very own Valheim dedicated server up and running. Not too much is known about Valheim right now due to just being released and i will update this guide as more is known. If you see any errors, please let me know and i will update them here in the guide.
- GUIDE INDEX
- Overview
- Introduction
- Installation of server files
- Server Configuration
- Running the server
- Comments
- Introduction
- This guide shows you what is required to get your very own Valheim dedicated server up and running. Not too much is known about Valheim right now due to just being released and i will update this guide as more is known. If you see any errors, please let me know and i will update them here in the guide.
- Installation of server files
- The first step is to retrieve the files for the game, this is done via SteamCMD.
- Follow the guide here on how to use STEAMCMD.
- Download SteamCMD for Windows: https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip
- Once you have STEAMCMD, run the following command:
- steamcmd +login anonymous +force_install_dir C:\valheimserver +app_update 896660 validate +exit
- Note: You can adjust the +force_install_dir parameter to the directory you want to download the server to.
- This will then download the entire game, Once completed, it's time to setup the server configuration.
- Server Configuration
- In this section we define the options on configuration and some basic commandline parameters
- The best method for a self-hosted solution is to use the provided .batch file
- Inside myserver\ folder where you downloaded the game files, create a bat file e.g. start.bat
- Inside the .bat file enter in this:
- start /high valheim_server -nographics -batchmode -name "SERVER NAME" -port 2456 -world "CHANGEME" -password "PASSWORD"
- Change parameters as required e.g.Change theport to the ports you want to use ( You will have to portforward/open them )
- Change name to what you want your server name to be.
- Change password to what you want.
- Running the server
- The best method for a self-hosted solution is to use the created .bat file you created above
- Inside the folder you set with steamcmd to install the files above, use the myserver\ folder where you downloaded the game files, Run Start.bat.
- Please note some port-forwarding may be required, by default the server will use port 2456 and 2457, each server should use unique ports and runs a separate process. You should unblock these port in your firewall\router.
- If setting up your own server is too much work for you, then please consider renting a server from Citadel Servers[citadelservers.com] - They setup everything for you and offer over 20 locations worldwide, i would highly recommend them
- ---------------------------------------------------------------
- source :
- https://steamcommunity.com/sharedfiles/filedetails/?id=2382282960
- Setting up a dedicated server (0.143.5)
- Info
- I've managed to download and run a server successfully with the steps below. I assume you have some basic knowledge of how servers and SteamCMD work, so the guide is very brief.
- SteamCMD and installing content
- Download SteamCMD from here. Extract it to any location. I keep my SteamCMD on my desktop.
- Create a .bat file (easiest way is to create a .txt file and save it as a .bat) named "update.bat" and paste the following in it:
- C:\Users\USERNAME\Desktop\SteamCMD\steamcmd +login anonymous +force_install_dir C:\Valheim +app_update 896660 validate +exit
- Change C:\Users\USERNAME\Desktop\SteamCMD\steamcmd to where you extracted SteamCMD.
- Change the +force_install_dir C:\Valheim to where you want to install the server.
- Save the .bat file and run it. When it has finished it should look like this in the folder you specified:
- Move your "update.bat" to the installation folder to keep it organized and run it when you want to update the server.
- Configure server
- Make a copy of the "start_headless_server.bat" in your server folder and rename it to "start.bat". Open "start.bat" with any text editor.
- I've marked the text you need to change with "CHANGEME" below, change them to what you want. When you're done, save and exit.
- -name | change this to the display name you want
- -world | change this to the name of your world. Needs to match if you're moving over local save files
- -password | change this to the password you want for the server (minimum 5 characters)
- @echo off
- set SteamAppId=892970
- echo "Starting server PRESS CTRL-C to exit"
- REM Tip: Make a local copy of this script to avoid it being overwritten by steam.
- REM NOTE: Minimum password length is 5 characters & Password cant be in the server name.
- REM NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall.
- valheim_server -nographics -batchmode -name "CHANGEME" -port 2456 -world "CHANGEME" -password "CHANGEME"
- Make sure ports 2456-2458 are open in your firewall on your router and PC. You can now start the server with the "start.bat" file. The server is ready when it says "Game server connected". To close down the server properly, open the server CMD prompt and press CTRL+C.
- Save location
- You can find your world in AppData\LocalLow\IronGate\Valheim. They can be moved to the dedicated server if it's on another PC, just make sure you name it the same in your "start.bat". You need to run the server once for the folder to generate.
- The server autosaves every 30 minutes.
- Direct Connect
- Go to Steam > View > Servers > Favorites > Add a server
- Put your machines IP and then port 2457 (default port +1 if you changed it), example: 192.168.1.20:2457
- You can now direct connect through the steam server browser. If you're connecting from the outside, put your exterior IP.
- It might show for a second and then disappear, make sure to double-click it instantly after refreshing. Not sure why this happens for me.
- ----------------------------
- Valheim Dedicated Linux Server
- By Griffen8280
- source : https://steamcommunity.com/sharedfiles/filedetails/?id=2387764236
- Assumptions
- It is assumed you have at least a working knowledge of Linux and can navigate around the operating system somewhat proficiently to complete this. Also I prefer to use the nano text editor on my system however if you use something else that is fine. Finally you will need to have steamcmd installed on your system in order for many of the things in this guide to work so ensure you have completed the steps outlined on the valve developer site to get it setup.
- https://developer.valvesoftware.com/wiki/SteamCMD
- Main install of the Server
- Warning:
- Make sure you replace all instances of "username" with your own in the code blocks!
- After you have steamcmd setup on your machine ensure you are back in the main directory of your account, this can be accomplished by typing:
- cd ~/
- Now create a folder at this location, I called mine Valheim (original right!)
- mkdir Valheim
- We are now ready to install the server files, using steamcmd by calling the whole thing from the command line with the following:
- /home/username/.steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/username/Valheim +app_update 896660 validate +exit
- This will install the server files into the Valheim directory we created earlier.
- Note:
- If you get the "No subscription" error when attempting to pull the files, then try to login using your normal steam credentials first. This will cache your account and then all calls using anonymous should work after that. - Thank you Tander for this tip!
- Modify the server start script
- Make sure you are in the Valheim directory and can see the files by executing the following:
- cd Valheim
- ls
- Something like this file list will appear...
- Now we get into the fun stuff, you need to make a copy of the server_start.sh file in the Valheim directory so that when steamcmd updates the server at some point your own changes are not overwritten and your service will still work. To do this execute the following on the command line:
- cp start_server.sh start_valheim.sh
- This will make a copy of the file and rename it start_valheim.sh, once that is done then we need to open the file and make a few edits to it.
- nano start_valheim.sh
- Once it is open copy the following block of code and paste it into the nano window using whatever method is convenient for you, or type it all in if you prefer. Note, this text should replace what is in the file. Or you could go line by line and just update your file with the stuff from below that is missing from yours.
- #!/bin/bash
- export templdpath=$LD_LIBRARY_PATH
- export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
- export SteamAppId=892970
- # Tip: Make a local copy of this script to avoid it being overwritten by steam.
- # NOTE: Minimum password length is 5 characters & Password cant be in the server name.
- # NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall.
- /home/username/.steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/username/Valheim +app_update 896660 +quit
- ./valheim_server.x86_64 -name "Your Server Name" -port 2456 -world "Dedicated" -password "Your Password" -public 1 > /dev/null &
- export LD_LIBRARY_PATH=$templdpath
- echo "Server started"
- echo ""
- #read -p "Press RETURN to stop server"
- #echo 1 > server_exit.drp
- #echo "Server exit signal set"
- #echo "You can now close this terminal"
- while :
- do
- TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
- echo "valheim.service: timestamp ${TIMESTAMP}"
- sleep 60
- done
- Again be sure to change any instance of "username" you find in the directory calls with your own username and change the server name and password to your own. When you are done with the file from nano you type in ctl+x and save it.
- A few things to note about the changes in this file are the while statement at the bottom. This is for the systemd journalctl service so that a running timestamp of how long the server is up can be written to the log. Also at the start of the script after the environment variables are set for the server to run correctly I am calling the steamcmd script to ensure that the server is the current version by running an update action. This makes it easy for you to create a cron to restart your server daily and when the service is started it will automatically check if there is an update for the server available from steam. Finally we comment out a few things at the bottom (echo statements) because they will not be needed to stop the server.
- Now we will need to create and register the service that will get this file running.
- Create and register the service
- Now we need to make a service file and do some editing to it in order to start this server in a nice way with the operating system.
- nano valheim.service
- That will create a file called "valheim.service" and open it automatically in the nano editor. Now paste the following contents into it...
- [Unit]
- Description=Valheim service
- Wants=network.target
- After=syslog.target network-online.target
- [Service]
- Type=simple
- Restart=on-failure
- RestartSec=10
- User=username
- WorkingDirectory=/home/username/Valheim
- ExecStart=/home/username/Valheim/start_valheim.sh
- [Install]
- WantedBy=multi-user.target
- What this is doing is creating the variables needed by the systemd daemon in order to start the server and manage it for you. In this we are telling the server not to attempt to start the service until after the network is online and logging has been started. In the [Service] section we are telling the system what type of service it is and what to do if it fails or crashes. Then we are telling it where the run script can be found/executed and what directory to work out of. Finally, since you never want to run a server (typically) as a root user we are defining the username to run the service as which should be your limited account. Again make sure you replace any instance of "username" you find with your own or this will not work as expected. Finally we need to copy this script into the proper directory and register it with the systemd daemon in order for it to be able to run.
- sudo cp valheim.service /etc/systemd/system
- Sudo is needed because you are copying this file to a protected system folder. Now register it with the systemd daemon
- sudo systemctl daemon-reload
- And finally we can start the service and see if everything is functional
- sudo systemctl start valheim
- Wait 10-15 seconds then
- sudo systemctl status valheim
- Once you execute all that you should see something similar to the following screenshot
- Of course you will see a few things after the name and password parts of the text, I blacked those out to protect my server :).
- Finally if you want to stop the server for any reason you can do the following
- sudo systemctl stop valheim
- Lastly if you want this to start auto-magically with the operating system just run the following
- sudo systemctl enable valheim.service
- Wrap up
- After you see that pretty green text that says active (running) that is it, your Valheim dedicated server is online. Finally you will need to forward the appropriate ports to your server which is outside the scope of this guide and when you log into the game you should be able to find your server in the server browser list and connect to it. Happy playing with your friends in a persistent dedicated world!
- Bonus:
- On my server I have set it up to check for OS updates and install them nightly then reboot the server, I have accomplished this with cron jobs and the following code will outline how to do that if you want a hands off type of install.
- sudo crontab -e
- This will open the system cron, then at the bottom of the file insert the following information.
- 0 2 * * * apt update && apt upgrade -y
- 30 2 * * * reboot
- 30 3 * * * apt autoremove && apt clean
- This will do the following on your server daily...
- Line 1 - Updates the repos on the system and then upgrades available packages at 2am
- Line 2 - Reboots the machine at 2:30am after the update
- Line 3 - Cleans up the apt system and removes deprecated packages at 3:30am
- This should keep your system updated and clean as well as restart the Valheim server on a nightly basis and check for updates for it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement