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

简介: 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

相关实践学习
2分钟自动化部署人生模拟器
本场景将带你借助云效流水线Flow实现人生模拟器小游戏的自动化部署
7天玩转云服务器
云服务器ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,可降低 IT 成本,提升运维效率。本课程手把手带你了解ECS、掌握基本操作、动手实操快照管理、镜像管理等。了解产品详情: https://www.aliyun.com/product/ecs
相关文章
|
14天前
|
存储 机器学习/深度学习 人工智能
2025年阿里云GPU服务器租用价格、选型策略与应用场景详解
随着AI与高性能计算需求的增长,阿里云提供了多种GPU实例,如NVIDIA V100、A10、T4等,适配不同场景。2025年重点实例中,V100实例GN6v单月3830元起,适合大规模训练;A10实例GN7i单月3213.99元起,适用于混合负载。计费模式有按量付费和包年包月,后者成本更低。针对AI训练、图形渲染及轻量级推理等场景,推荐不同配置以优化成本和性能。阿里云还提供抢占式实例、ESSD云盘等资源优化策略,支持eRDMA网络加速和倚天ARM架构,助力企业在2025年实现智能计算的效率与成本最优平衡。 (该简介为原文内容的高度概括,符合要求的字符限制。)
|
15天前
|
存储 弹性计算 人工智能
2025年阿里云企业云服务器ECS选购与配置全攻略
本文介绍了阿里云服务器的核心配置选择方法论,涵盖算力需求分析、网络与存储设计、地域部署策略三大维度。针对不同业务场景,如初创企业官网和AI模型训练平台,提供了具体配置方案。同时,详细讲解了购买操作指南及长期运维优化建议,帮助用户快速实现业务上云并确保高效运行。访问阿里云官方资源聚合平台可获取更多最新产品动态和技术支持。
|
5天前
|
人工智能 负载均衡 数据可视化
阿里云出手了,DeepSeek服务器拒绝繁忙,免费部署DeepSeek模型671B满血版
阿里云推出免费部署DeepSeek模型671B满血版服务,通过百炼大模型平台,用户无需编码,最快5分钟、最低0元即可完成部署。平台提供100万免费Token,支持DeepSeek-R1和DeepSeek-V3等多款模型调用,有效解决服务器繁忙问题。新手零基础也能轻松上手,享受高效稳定的API调用和自动弹性扩展功能。教程涵盖开通服务、获取API-KEY及配置Chatbox客户端等步骤,详细指引助您快速实现DeepSeek自由。
72 18
|
1天前
|
Kubernetes 监控 Serverless
基于阿里云Serverless Kubernetes(ASK)的无服务器架构设计与实践
无服务器架构(Serverless Architecture)在云原生技术中备受关注,开发者只需专注于业务逻辑,无需管理服务器。阿里云Serverless Kubernetes(ASK)是基于Kubernetes的托管服务,提供极致弹性和按需付费能力。本文深入探讨如何使用ASK设计和实现无服务器架构,涵盖事件驱动、自动扩展、无状态设计、监控与日志及成本优化等方面,并通过图片处理服务案例展示具体实践,帮助构建高效可靠的无服务器应用。
|
3天前
|
存储 编解码 大数据
阿里云服务器实例选择参考:根据业务场景选择云服务器实例规格
对于初次接触阿里云服务器的用户来说,面对众多实例规格往往不知道如何选择,因为云服务器实例规格不同,价格也不一样,往往会感到无从下手。本文旨在通过详细解析阿里云服务器的不同实例规格及其适用场景,为用户提供一份实用的选型指南,以供参考。
|
11天前
|
存储 弹性计算 数据挖掘
阿里云ECS云服务器经济型e实例和通用算力型u1实例区别对比、适用场景和问题解答FAQ
阿里云ECS云服务器的经济型e实例和通用算力型u1实例是开发者和中小企业常用的两种配置。e实例适合中小型网站、开发测试等轻量级应用,性价比高;u1实例性能更优,适用于中小型企业级应用、数据分析等场景。同等配置下,u1实例在网络带宽、云盘IOPS等方面表现更好,价格也相对较高。选择时,个人用户推荐e实例,中小企业则更适合u1实例
|
12天前
|
机器学习/深度学习 人工智能 程序员
阿里云出手DeepSeek拒绝服务器繁忙,程序员直呼:真香!
阿里云PAI平台支持一键部署DeepSeek-V3和DeepSeek-R1大模型,用户无需编写代码即可完成从训练到部署的全过程。通过PAI Model Gallery,开发者可轻松选择并部署所需模型版本,享受高效、便捷的AI开发体验。教程详细介绍了开通PAI、选择模型及一键部署的具体步骤,帮助用户快速上手。
|
1天前
|
安全 JavaScript 测试技术
阿里云轻量应用服务器38元1年性能、适用场景简单测评
在阿里云目前的活动中,轻量云服务器2核2G200M峰值带宽每天10点和15点抢购价只要38元一年,e实例云服务器2核2G3M带宽99元1年,u1实例2核4G5M带宽199元一年。其中,阿里云轻量应用服务器38元1年的抢购价,让不少用户心动不已。那么,这款特价轻量应用服务器到底怎么样?是否值得购买呢?本文将从配置、性能、适用场景、价格优势等多个方面对这款轻量应用服务器做个介绍,以供参考。
阿里云轻量应用服务器38元1年性能、适用场景简单测评
|
7天前
|
人工智能 负载均衡 数据可视化
阿里云出手了,基于百炼一键部署DeepSeek满血版,告别服务器繁忙1
阿里云百炼平台推出一键部署DeepSeek-R1满血版671B模型,提供100万免费Token,无需编码,新手5分钟内即可完成部署。通过Chatbox客户端配置API,轻松实现模型调用,解决服务器繁忙问题,支持自动弹性扩展,降低硬件成本。详情及教程见阿里云百炼官网。
168 5
|
14天前
|
存储 人工智能 弹性计算
2025年阿里云企业高性能云服务器租用价格与选型详解
随着企业数字化转型,阿里云于2025年推出多款高性能云服务器实例,涵盖计算、通用和内存密集型场景。文章分析了企业选择云服务器的核心要点,包括明确业务需求(如计算密集型任务推荐计算型实例)、性能与架构升级(如第八代实例性能提升20%),以及第九代实例支持AI等高算力需求。同时提供了配置价格参考和成本优化策略,助力企业实现效率与成本的最优平衡。