请注意,本文编写于 1216 天前,最后修改于 21 天前,其中某些信息可能已经过时。
准备工作
先对系统进行更新(这一步不是必须):
Debian:
apt update && apt upgrade -y
CentOS:
yum update -yCentOS 需要安装 EPEL 源:
yum -y install epel-release安装常用工具:
Debian:
apt -y install vim curl wget tar gzip2 bzip
CentOS:
yum -y install vim curl wget tar gzip2 bzipCentOS 需要手动安装 CSGO 服务器依赖:
yum -y install nmap-ncat mailx postfix unzip python3 binutils bc jq tmux glibc.i686 libstdc++ libstdc++.i686数据库依赖:
Debian:
apt -y install lib32z1
CentOS:
yum -y install zlib.i686参考:
https://bbs.csgocn.net/thread-22.htm
安装宝塔
宝塔可以用于搭建:
- MySQL
- 网站
- FastDL
- 管理服务器
Debian:
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh
CentOS:
wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh官方说明:
https://www.bt.cn/btcode.html#mysql
安装 LinuxGSM
LinuxGSM 不允许 root 运行,需要新建用户。
Debian
sudo useradd -m csgo -g sudo -s /bin/bash -d /home/csgo
sudo passwd csgoCentOS
adduser csgo
passwd csgo添加 sudo 权限
vim /etc/sudoers在 %wheel ALL=(ALL) ALL 下面添加:
csgo ALL=(ALL) NOPASSWD:ALL保存退出:
:wq!切换用户
su - csgo
cd安装 LinuxGSM
curl -Lo linuxgsm.sh https://resources.sfwww.cn/d/resource/LinuxGSM/linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh csgoserver然后执行:
./csgoserver install系统会自动:
- 安装 SteamCMD
- 下载 CSGO Server
- 安装依赖
GSLT Token
CSGO 联机服务器需要 GSLT Token。
获取地址:
https://steamcommunity.com/dev/managegameservers
创建后保存 Token。
修改配置文件
进入配置目录:
cd /home/csgo/lgsm/config-lgsm/csgoserver复制默认配置:
cat _default.cfg > csgoserver.cfg编辑:
vim csgoserver.cfg需要修改的重要参数:
| 参数 | 作用 |
|---|---|
| game_type | 游戏模式 |
| game_mode | 游戏模式 |
| port | 服务器端口 |
| defaultmap | 默认地图 |
| maxplayers | 最大人数 |
| tickrate | tick率 |
| gslt | 服务器登录令牌 |
游戏模式
| 模式 | game_type | game_mode |
|---|---|---|
| 休闲 | 0 | 0 |
| 竞技 | 0 | 1 |
| 军备竞赛 | 1 | 0 |
| 爆破 | 1 | 1 |
| 死亡竞赛 | 1 | 2 |
游戏配置文件
编辑:
vim /home/csgo/serverfiles/csgo/cfg/csgoserver.cfg示例:
sv_setsteamaccount "TOKEN"
hostname "CSGO服务器"
sv_region 4
rcon_password ""
sv_password ""
sv_maxrate "196608"
sv_minrate "80000"
mp_match_end_restart 0
mp_autokick 0安装插件
返回主目录:
cd安装插件管理:
./csgoserver mi先安装:
metamodsource再安装:
sourcemod添加管理员
echo '"STEAMID" "99:z"' >> /home/csgo/serverfiles/csgo/addons/sourcemod/configs/admins_simple.ini格式:
"STEAM_1:1:122170925" "z"获取 SteamID:
常见插件
枪皮插件
https://github.com/kgns/weapons/releases/latest
依赖:
手套插件
https://github.com/kgns/gloves/
探员插件
https://github.com/RoyZ-CSGO/Franug-AgentsChooser
开放端口
su - root
firewall-cmd --zone=public --add-port=27015/tcp --permanent
firewall-cmd --zone=public --add-port=27015/udp --permanent
firewall-cmd --reload
firewall-cmd --list-portsCSGO 主要使用 UDP。
自动更新
crontab -e添加:
*/30 * * * * /home/csgoserver/csgoserver update > /dev/null 2>&1
0 0 * * 0 /home/csgoserver/csgoserver update-lgsm > /dev/null 2>&1LinuxGSM 常用命令
./csgoserver start
./csgoserver stop
./csgoserver restart
./csgoserver update
./csgoserver consoleScreen 后台运行
安装:
yum install screen创建会话:
screen -S cs后台运行:
Ctrl + A
Ctrl + D查看:
screen -ls进入:
screen -r cs常用 CSGO 指令
bot_quota 5
bot_quota_mode fill
mp_autoteambalance 0
mp_limitteams 0
mp_maxrounds 30
mp_warmuptime 10
mp_freezetime 0
mp_free_armor 2
sv_full_alltalk 1
mp_startmoney 60000
mp_maxmoney 60000启动参数示例
startparameters="-game csgo -usercon -nobots -nomaster -strictportbind -ip ${ip} -port ${port} +sv_setsteamaccount ${gslt} -tickrate ${tickrate} +map ${defaultmap} -maxplayers_override ${maxplayers} +game_type ${gametype} +game_mode ${gamemode}"示例配置:
tickrate=128
defaultmap=de_dust2
maxplayers=10
gametype=0
gamemode=1常见问题
更新错误 0x202
Error! App '740' state is 0x202原因:
服务器磁盘空间不足。
解决:
删除旧地图或扩容磁盘。
GSLT 失效
服务器长时间不用会失效。
解决:
重新申请 GSLT。
至此 CSGO 服务器部署完成。
のBlog
2 条评论
更新后不能启动服务器了怎么解决
请参考CentOS-7.6版本的内核问题