Centos 7.6 服务器系统怎么架设传奇?Linux 环境分步指南

来源: 作者: 点击:
一、Centos 7.6 前期准备(系统与工具)
系统基础配置
确认系统版本:通过远程连接工具输入cat /etc/redhat-release,验证是否为 CentOS Linux release 7.6.x,建议使用 64 位系统(32 位系统易出现内存不足问题)。
关闭 SELinux:编辑/etc/selinux/config文件,将SELINUX=enforcing改为SELINUX=disabled,执行setenforce 0临时生效,避免拦截服务端进程。
划分目录:执行mkdir -p /usr/local/legend/server /usr/local/legend/data,分别存放服务端程序与数据库文件,便于后续管理。
必备工具清单(Linux 适配版)
远程连接工具:Xshell(命令行操作)、WinSCP(可视化文件传输,方便 Windows 与 Centos 互传文件);
传奇服务端:选择 Linux 兼容版(如 1.76 复古 Linux 端,避免使用 Windows 服务端,会出现运行报错);
数据库:MariaDB 5.5(Centos 7.6 默认兼容版本,替代 MySQL,避免高版本数据库适配问题);
依赖库:gcc、glibc-devel、net-tools(服务端编译与运行必备,需通过 yum 命令安装);
文本编辑器:Notepad++(本地修改服务端配置文件,支持 Linux 格式编码);
Linux 登录器:侠客登录器 Linux 版(生成客户端可识别的登录程序,支持跨系统连接)。
二、Centos 7.6 环境搭建(核心步骤)
安装依赖库与基础工具
执行以下命令批量安装依赖:
yum install -y gcc glibc-devel net-tools mariadb-server mariadb
启动 MariaDB 并设置开机自启:
systemctl start mariadb
systemctl enable mariadb
初始化数据库(设置 root 密码,删除匿名账号):
执行mysql_secure_installation,按提示输入密码(建议记录),依次选择 “Y” 确认删除匿名账号、禁止 root 远程登录(若需远程管理,后续可单独授权)。
配置传奇数据库
登录 MariaDB:mysql -u root -p,输入密码后进入数据库命令行;
创建传奇专用数据库并授权:
create database legend_db character set utf8;
grant all privileges on legend_db.* to 'legend_user'@'localhost' identified by '你的密码';
flush privileges;
导入服务端 SQL 文件:
通过 WinSCP 将服务端自带的db.sql上传至/usr/local/legend/data,执行mysql -u legend_user -p legend_db < /usr/local/legend/data/db.sql,输入密码完成导入,随后输入exit退出数据库。
三、Centos 7.6 传奇服务端部署
服务端文件传输与解压
通过 WinSCP 将 Linux 版传奇服务端压缩包(如legend_server.tar.gz)上传至/usr/local/legend/server;
执行命令解压:
tar -zxvf /usr/local/legend/server/legend_server.tar.gz -C /usr/local/legend/server
赋予服务端执行权限(Centos 权限严格,必须操作,否则无法启动):
chmod +x /usr/local/legend/server/*.sh
chmod +x /usr/local/legend/server/GameSrv /usr/local/legend/server/LoginSrv
修改服务端配置文件
编辑服务端 IP 与端口配置:
执行vi /usr/local/legend/server/Config/ServerInfo.conf,按i进入编辑模式,将ServerIP改为服务器公网 IP,ServerPort设为 7000(默认未占用端口),按Esc后输入:wq保存退出;
调整游戏参数:
编辑/usr/local/legend/server/Config/GameConfig.conf,修改经验倍率(如ExpRate=5)、金币掉落率(GoldRate=3),保存方式同上。
启动服务端进程
执行启动脚本(后台运行,避免关闭 Xshell 后进程终止):
nohup /usr/local/legend/server/StartServer.sh &
验证进程是否正常:
执行ps aux | grep GameSrv,若显示GameSrv与LoginSrv进程,说明启动成功;若提示 “缺失 libxxx.so”,需通过yum install安装对应缺失库(如yum install -y libstdc++.so.6)。
四、登录器适配与网络配置
生成 Linux 兼容登录器
通过 WinSCP 将 Linux 登录器生成工具上传至/usr/local/legend/server,赋予执行权限:chmod +x /usr/local/legend/server/LoginMaker;
执行登录器生成命令:
cd /usr/local/legend/server
./LoginMaker -ip 你的公网IP -port 7000 -out /usr/local/legend/server/LegendLogin.exe
通过 WinSCP 将生成的LegendLogin.exe下载至本地,复制到传奇客户端根目录。
开放服务器端口(防火墙配置)
Centos 7.6 默认使用 firewalld 防火墙,执行以下命令开放 7000 端口:
firewall-cmd --zone=public --add-port=7000/tcp --permanent
firewall-cmd --reload
验证端口是否开放:firewall-cmd --zone=public --query-port=7000/tcp,显示 “yes” 即配置成功。
五、Centos 7.6 架设常见问题解决
服务端启动后进程立即消失
执行cat nohup.out查看错误日志,若提示 “数据库连接失败”,检查ServerInfo.conf中数据库账号密码是否与 MariaDB 配置一致;若提示 “权限不足”,重新执行chmod +x赋予所有服务端文件执行权限。
远程客户端无法连接服务器
排查步骤:① 执行netstat -tuln | grep 7000,确认端口是否处于监听状态;② 检查服务器公网 IP 是否正确(可通过curl ifconfig.me获取);③ 若使用云服务器,需在控制台安全组中额外开放 7000 端口(部分云厂商防火墙与系统防火墙独立)。
游戏内中文乱码
编辑/etc/profile文件,添加编码配置:
echo "export LANG=en_US.UTF-8" >> /etc/profile
source /etc/profile
重启服务端:pkill GameSrv,再执行nohup /usr/local/legend/server/StartServer.sh &。
MariaDB 无法远程连接(需管理数据库时)
登录 MariaDB 授权远程访问:
mysql -u root -p
grant all privileges on *.* to 'root'@'%' identified by '你的密码';
flush privileges;
开放 3306 端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent,重新加载防火墙后即可通过 Navicat 远程连接。