Advertisement
Button_Pusher_

Valheim Dedicated Game Server Setup Guides

Feb 11th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.37 KB | None | 0 0
  1. Valheim Dedicated Game Server Setup Guides
  2.  
  3. **LINUX USERS SEE BOTTOM OF FILE
  4.  
  5. ---------------------------------------------------------
  6.  
  7. source :
  8. https://steamcommunity.com/sharedfiles/filedetails/?id=2383801614
  9.  
  10.  
  11. 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.
  12.  
  13.  
  14. GUIDE INDEX
  15. Overview
  16. Introduction
  17. Installation of server files
  18. Server Configuration
  19.  
  20. Running the server
  21. Comments
  22. Introduction
  23. 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.
  24. Installation of server files
  25. The first step is to retrieve the files for the game, this is done via SteamCMD.
  26.  
  27. Follow the guide here on how to use STEAMCMD.
  28.  
  29. Download SteamCMD for Windows: https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip
  30.  
  31. Once you have STEAMCMD, run the following command:
  32.  
  33. steamcmd +login anonymous +force_install_dir C:\valheimserver +app_update 896660 validate +exit
  34.  
  35. Note: You can adjust the +force_install_dir parameter to the directory you want to download the server to.
  36.  
  37. This will then download the entire game, Once completed, it's time to setup the server configuration.
  38. Server Configuration
  39. In this section we define the options on configuration and some basic commandline parameters
  40.  
  41. The best method for a self-hosted solution is to use the provided .batch file
  42.  
  43. Inside myserver\ folder where you downloaded the game files, create a bat file e.g. start.bat
  44.  
  45. Inside the .bat file enter in this:
  46.  
  47. start /high valheim_server -nographics -batchmode -name "SERVER NAME" -port 2456 -world "CHANGEME" -password "PASSWORD"
  48.  
  49. Change parameters as required e.g.Change theport to the ports you want to use ( You will have to portforward/open them )
  50.  
  51. Change name to what you want your server name to be.
  52.  
  53. Change password to what you want.
  54. Running the server
  55. The best method for a self-hosted solution is to use the created .bat file you created above
  56.  
  57. 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.
  58.  
  59. 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.
  60.  
  61. 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
  62.  
  63.  
  64.  
  65. ---------------------------------------------------------------
  66.  
  67. source :
  68.  
  69. https://steamcommunity.com/sharedfiles/filedetails/?id=2382282960
  70.  
  71.  
  72.  
  73. Setting up a dedicated server (0.143.5)
  74.  
  75. Info
  76. 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.
  77. SteamCMD and installing content
  78. Download SteamCMD from here. Extract it to any location. I keep my SteamCMD on my desktop.
  79.  
  80. 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:
  81.  
  82. C:\Users\USERNAME\Desktop\SteamCMD\steamcmd +login anonymous +force_install_dir C:\Valheim +app_update 896660 validate +exit
  83.  
  84. Change C:\Users\USERNAME\Desktop\SteamCMD\steamcmd to where you extracted SteamCMD.
  85. Change the +force_install_dir C:\Valheim to where you want to install the server.
  86. Save the .bat file and run it. When it has finished it should look like this in the folder you specified:
  87.  
  88.  
  89.  
  90. Move your "update.bat" to the installation folder to keep it organized and run it when you want to update the server.
  91. Configure server
  92. 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.
  93.  
  94. 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.
  95.  
  96. -name | change this to the display name you want
  97. -world | change this to the name of your world. Needs to match if you're moving over local save files
  98. -password | change this to the password you want for the server (minimum 5 characters)
  99.  
  100. @echo off
  101. set SteamAppId=892970
  102.  
  103. echo "Starting server PRESS CTRL-C to exit"
  104.  
  105. REM Tip: Make a local copy of this script to avoid it being overwritten by steam.
  106. REM NOTE: Minimum password length is 5 characters & Password cant be in the server name.
  107. REM NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall.
  108. valheim_server -nographics -batchmode -name "CHANGEME" -port 2456 -world "CHANGEME" -password "CHANGEME"
  109.  
  110. 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.
  111. Save location
  112. 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.
  113.  
  114. The server autosaves every 30 minutes.
  115.  
  116.  
  117. Direct Connect
  118. Go to Steam > View > Servers > Favorites > Add a server
  119.  
  120. Put your machines IP and then port 2457 (default port +1 if you changed it), example: 192.168.1.20:2457
  121.  
  122. You can now direct connect through the steam server browser. If you're connecting from the outside, put your exterior IP.
  123.  
  124. 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.
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. ----------------------------
  134.  
  135.  
  136. Valheim Dedicated Linux Server
  137. By Griffen8280
  138.  
  139. source : https://steamcommunity.com/sharedfiles/filedetails/?id=2387764236
  140.  
  141. Assumptions
  142. 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.
  143.  
  144. https://developer.valvesoftware.com/wiki/SteamCMD
  145. Main install of the Server
  146. Warning:
  147. Make sure you replace all instances of "username" with your own in the code blocks!
  148.  
  149. 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:
  150.  
  151. cd ~/
  152.  
  153. Now create a folder at this location, I called mine Valheim (original right!)
  154.  
  155. mkdir Valheim
  156.  
  157. We are now ready to install the server files, using steamcmd by calling the whole thing from the command line with the following:
  158.  
  159. /home/username/.steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/username/Valheim +app_update 896660 validate +exit
  160.  
  161. This will install the server files into the Valheim directory we created earlier.
  162.  
  163. Note:
  164. 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!
  165. Modify the server start script
  166. Make sure you are in the Valheim directory and can see the files by executing the following:
  167.  
  168. cd Valheim
  169. ls
  170.  
  171. Something like this file list will appear...
  172.  
  173.  
  174. 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:
  175.  
  176. cp start_server.sh start_valheim.sh
  177.  
  178. 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.
  179.  
  180. nano start_valheim.sh
  181.  
  182. 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.
  183.  
  184. #!/bin/bash
  185.  
  186. export templdpath=$LD_LIBRARY_PATH
  187. export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
  188. export SteamAppId=892970
  189.  
  190. # Tip: Make a local copy of this script to avoid it being overwritten by steam.
  191. # NOTE: Minimum password length is 5 characters & Password cant be in the server name.
  192. # NOTE: You need to make sure the ports 2456-2458 is being forwarded to your server through your local router & firewall.
  193. /home/username/.steam/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/username/Valheim +app_update 896660 +quit
  194.  
  195. ./valheim_server.x86_64 -name "Your Server Name" -port 2456 -world "Dedicated" -password "Your Password" -public 1 > /dev/null &
  196.  
  197. export LD_LIBRARY_PATH=$templdpath
  198.  
  199. echo "Server started"
  200. echo ""
  201. #read -p "Press RETURN to stop server"
  202. #echo 1 > server_exit.drp
  203.  
  204. #echo "Server exit signal set"
  205. #echo "You can now close this terminal"
  206.  
  207. while :
  208. do
  209. TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
  210. echo "valheim.service: timestamp ${TIMESTAMP}"
  211. sleep 60
  212. done
  213.  
  214. 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.
  215.  
  216. 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.
  217.  
  218. Now we will need to create and register the service that will get this file running.
  219. Create and register the service
  220. 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.
  221.  
  222. nano valheim.service
  223.  
  224. That will create a file called "valheim.service" and open it automatically in the nano editor. Now paste the following contents into it...
  225.  
  226. [Unit]
  227. Description=Valheim service
  228. Wants=network.target
  229. After=syslog.target network-online.target
  230.  
  231. [Service]
  232. Type=simple
  233. Restart=on-failure
  234. RestartSec=10
  235. User=username
  236. WorkingDirectory=/home/username/Valheim
  237. ExecStart=/home/username/Valheim/start_valheim.sh
  238.  
  239. [Install]
  240. WantedBy=multi-user.target
  241.  
  242. 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.
  243.  
  244. sudo cp valheim.service /etc/systemd/system
  245.  
  246. Sudo is needed because you are copying this file to a protected system folder. Now register it with the systemd daemon
  247.  
  248. sudo systemctl daemon-reload
  249.  
  250. And finally we can start the service and see if everything is functional
  251.  
  252. sudo systemctl start valheim
  253.  
  254. Wait 10-15 seconds then
  255.  
  256. sudo systemctl status valheim
  257.  
  258. Once you execute all that you should see something similar to the following screenshot
  259.  
  260.  
  261. 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 :).
  262.  
  263. Finally if you want to stop the server for any reason you can do the following
  264.  
  265. sudo systemctl stop valheim
  266.  
  267. Lastly if you want this to start auto-magically with the operating system just run the following
  268.  
  269. sudo systemctl enable valheim.service
  270. Wrap up
  271. 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!
  272.  
  273. Bonus:
  274.  
  275. 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.
  276.  
  277. sudo crontab -e
  278.  
  279. This will open the system cron, then at the bottom of the file insert the following information.
  280.  
  281. 0 2 * * * apt update && apt upgrade -y
  282. 30 2 * * * reboot
  283. 30 3 * * * apt autoremove && apt clean
  284.  
  285. This will do the following on your server daily...
  286. Line 1 - Updates the repos on the system and then upgrades available packages at 2am
  287. Line 2 - Reboots the machine at 2:30am after the update
  288. Line 3 - Cleans up the apt system and removes deprecated packages at 3:30am
  289.  
  290. 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.
  291.  
  292.  
  293.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement