使用阿里云服务器为我的小伙伴们创建游戏服务器~

简介: steamCMD在linux上可以很方便的创建游戏服务器文件,只需要按照步骤安装和配置,之后启动服务器脚本就可以开启服务器了,1核2G的服务器,我们俩人玩了三个小时,之后开始变得不流畅起来,所以要想保障体验的话最好是2核4G的服务器估计能满足正常的时间分布。

Valheim server on Linux
Here is a step-by-step guide for setting up a Valheim server on Linux. Having done it twice now I thought it would be a good idea to capture this somewhere so that next time I don't have to look any of this up again.

The only assumptions being made here is that your server is running Ubuntu of some semi-recent version and a basic understanding of Linux.

SteamCMD
The SteamCMD utility from Valve will help us install the gamefiles on the server. Follow the instructions on the wiki to get it up and running.

Valheim
Now that SteamCMD is available, we can use it to download the gamefiles to the server.

steamcmd +login anonymous +force_install_dir

/home/steam/.steam/steamapps/common/valheim +app_update 896660 validate +exit

Some things to note here:

I've forced the install directory to something without spaces or other special crap in the name. This will make setting up systemd easier later.
896660 is the steam identifier for Valheim.
You can re-use this command later when you need to update the gamefiles when the devs release an update.
For quick re-use, create an sh file and put the command in there. I've named my update_game.sh, mark the file as executable and you're all set.

There are some last changes before we can run the server.

Valheim server configuration
There is not a lot to change but it's a requirement if you want to set up things correctly. Browse to the folder where you installed the game and look for a file called start_server.sh. As instructed in the file, make a copy of it (for simplicity I've named mine start_valheim.sh). Here's what mine looks like:

export TERM=xterm
export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970

echo "Starting server PRESS CTRL-C to exit"

./valheim_server.x86_64 -name "Helheim" -port 2456 -world "Dedicated" -password "..."
export LD_LIBRARY_PATH=$templdpath

I've added an additional export at the top (found after a bunch of searching for specific problems) to prevent some warnings and errors while the game starts. You could maybe get by without it, it'll depend on the rest of your system. If you see weird stuff in the game output, it's worth a shot.

Update the value for the -name argument to something you nice and of course set the -password value. Make sure it is longer than 5 characters and is not your server name.

Port configuration
This step will depend on your network infrastructure, I'm running my server on the Azure cloud platform which has its own way of configuring ports for VMs. Your setup is probably different but the gist of all of it is that you need op open the port range 2456-2458 for incoming traffic.

Running the server
It's tempting now to just run the > start_valheim.sh> file and start gaming but that comes with a drawback. When you close your SSH session, your server will stop. To fix that we'll use systemd to run the gameserver for us (and even try to restart it should it for some
reason crash or shut down).

Here is the config file I'm using:

[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/.steam/steamapps/common/valheim/
ExecStart=/bin/sh /home/steam/.steam/steamapps/common/valheim/start_valheim.sh

[Install]
WantedBy=multi-user.target
If you've stuck with the same names for files and directories you can copy-paste this into a file called valheim.service and roll with that, or change it, if needed.

Given the systemd config file above, we can now hand this over to systemd to hand off the running and monitoring of the server. First step is to install the service file.

Copy the file to /etc/systemd/system.
Activate the service so that systemd can start the service: sudo systemctl enable valheim (don't include the .service part here).
Start the service: sudo systemctl start valheim.
Check the server status and see if it's actually running: sudo systemctl status valheim.
If everything was set up correctly, the output of step 4 will show a line that looks something like this (truncated for brevity):

● valheim.service - Valheim service
    Loaded: loaded (/etc/systemd/system/valheim.service; enabled; vendor preset: enabled)
    Active: active (running)
journalctl -u valheim -n 20

Wrapping up
At this point you should be able to use the public IP of your server to start playing! I don't know much about the resources required to keep everthing running smoothly but I've been running a server on a fairly modest 2-core/8GB RAM Linux (Standard D2as_v4 on Azure) VM that can easily host a 4 player game.

Now go forth and play the viking game with your friends on your very own Valheim server!

Posted on 2021-09-12
Tagged Gaming, Linux

© 2022 harrewijnen.net

相关实践学习
通义万相文本绘图与人像美化
本解决方案展示了如何利用自研的通义万相AIGC技术在Web服务中实现先进的图像生成。
7天玩转云服务器
云服务器ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,可降低 IT 成本,提升运维效率。本课程手把手带你了解ECS、掌握基本操作、动手实操快照管理、镜像管理等。了解产品详情: https://www.aliyun.com/product/ecs
相关文章
|
14天前
|
开发框架 JavaScript .NET
阿里云轻量应用服务器2核2G38元1年起怎么样?性能、应用场景与购买价值参考
目前在阿里云的活动中,抢购价为38元1年的轻量应用服务器受到了众多个人和中小企业用户的高度关注,该款轻量应用服务器置为2核CPU、2G内存,峰值带宽达200M。那么,此款轻量应用服务器的具体性能如何?适用于哪些应用场景?是否具备较高的购买价值?本文将针对这款特惠轻量应用服务器展开全面且深入的测评与介绍。
263 30
阿里云轻量应用服务器2核2G38元1年起怎么样?性能、应用场景与购买价值参考
|
5天前
|
自然语言处理 监控 数据可视化
如何建设网站:使用阿里云的服务器网站建设5大步骤
企业用阿里云服务器建网站,无需复杂技术,按五步骤即可。先规划需求明确网站功能;再选入门级服务器并初始化;接着部署 PageAdmin CMS,可视化操作易上手;然后选模板填内容搭建网站;最后测试适配与稳定性,绑定域名备案后上线。PageAdmin 还方便后期维护调整。
98 10
|
7天前
|
弹性计算 搜索推荐 异构计算
阿里云服务器收费标准:2025年10月最新价格表,ECS、轻量和GPU云服务器报价清单
2025年10月阿里云服务器优惠延续,轻量应用服务器200M带宽38元/年起,ECS 2核2G 99元/年、2核4G 199元/年,4核16G 89元/月,8核32G 160元/月,香港轻量25元/月起,新老用户同享,续费不涨价。
|
6天前
|
弹性计算 Windows
阿里云香港服务器收费价格:香港ECS和轻量应用服务器配置介绍
2025年阿里云香港服务器优惠汇总:ECS 2核4G+5M带宽仅199元/年;轻量服务器30M带宽24元/月起,200M峰值带宽25元/月起。轻量性价比高,适合个人及中小企业建站、跨境业务,具体配置价格详见官方活动页。
136 1
|
19天前
|
存储 弹性计算 应用服务中间件
阿里云轻量应用服务器与云服务器ECS有何区别?轻量应用服务器性能、优势与收费价格参考
2025年,阿里云轻量应用服务器2核2G3M带宽搭配40GB ESSD云盘的配置,每天10点和15点开启的抢购价只要38元1年,新用户非抢购专属优惠价也只要68元1年。对于一些初次接触阿里云轻量应用服务器的用户来说,可能不是很清楚它与云服务器ECS有什么不同?选择轻量应用服务器有哪些优势,本文为大家介绍轻量应用服务器的性能、适用场景、优势、收费标准以及与云服务器ECS之间的区别,以供参考。
|
16天前
|
弹性计算 运维 安全
轻量级应用服务器和云服务器区别——阿里云轻量和ECS区别对比
阿里云轻量应用服务器与ECS云服务器对比:轻量适合个人开发者、学生搭建博客、测试环境,门槛低、操作简便、成本低;ECS适用于企业级高并发场景,功能全面、弹性强。二者在使用场景、性能、网络、镜像及运维管理等方面差异显著,用户应根据实际需求选择。
155 4
|
17天前
|
存储 缓存 数据挖掘
阿里云轻量应用服务器“CPU优化型”配置介绍、费用价格说明
阿里云轻量应用服务器推出CPU优化型,提供更强计算性能,2核4GB起,最高16核64GB,全系支持200Mbps带宽。适用于企业级应用、数据库、游戏服务器等高算力场景,保障稳定高效运行。
152 1
|
24天前
|
运维 安全 测试技术
云服务器还是物理服务器?企业如何根据需求做出正确决策
在数字化转型的浪潮中,企业的基础架构选择至关重要。当业务发展到一定阶段,“物理服务器”还是“云服务器”这个问题必然会摆在决策者面前。两者并非简单的谁替代谁的关系,而是各有优劣,适用于不同的业务场景。本文将为您全面解析物理服务器与云服务器的核心差异,助您做出最明智的选择。
|
1月前
|
存储 缓存 数据挖掘
阿里云目前最便宜云服务器介绍:38元、99元、199元性能,选购攻略参考
轻量应用服务器2核2G峰值200M带宽38元1年;云服务器经济型e实例2核2G3M带宽99元1年;云服务器通用算力型u1实例2核4G5M带宽199元1年。对于还未使用过阿里云服务器的用户来说,大家也不免有些疑虑,这些云服务器性能究竟如何?它们适用于哪些场景?能否满足自己的使用需求呢?接下来,本文将为您全方位介绍这几款云服务器,以供您了解及选择参考。
|
2月前
|
网络安全 云计算
如何设置阿里云轻量应用服务器镜像?
本文介绍了在阿里云轻量应用服务器上创建与配置镜像的详细步骤。镜像是一种特殊的文件系统映射,可用于快速克隆服务器配置。内容涵盖准备条件、登录控制台、创建实例、生成镜像、下载与设置镜像,以及如何使用镜像启动新实例。适合希望提升服务器部署效率的用户参考。

热门文章

最新文章