一、Linux 各系列前期通用准备
系统版本确认(关键第一步)
CentOS:执行cat /etc/redhat-release,确认版本(如 CentOS 7.x、8.x,7.x 系列兼容性最佳);
Ubuntu:执行lsb_release -a,推荐 20.04 LTS 或 22.04 LTS 版本(长期支持版稳定性高);
Debian:执行cat /etc/debian_version,选择 10(Buster)或 11(Bullseye)版本(适配多数传奇服务端);
统一要求:均使用 64 位系统,32 位系统易出现内存不足或依赖库缺失问题。
必备工具清单(跨系列适配版)
远程工具:Xshell(命令行操作)、WinSCP(可视化传文件,Windows 与 Linux 互传通用);
传奇服务端:选择 Linux 通用版或对应系统适配版(如 “Linux 全系列兼容 1.76 复古端”,避免 Windows 端,会报错);
数据库:MariaDB 5.5-10.5(各系列均兼容,替代 MySQL,高版本易适配失败);
依赖库:gcc、glibc-devel、net-tools(CentOS 用 yum 装,Ubuntu/Debian 用 apt 装,服务端运行必需);
编辑器:Notepad++(本地改配置文件,支持 Linux 编码,避免乱码);
登录器:Linux 通用版侠客登录器(生成客户端可识别的.exe 文件,跨系统连接无压力)。
通用系统配置
关闭 SELinux(仅 CentOS 需操作):编辑/etc/selinux/config,改SELINUX=enforcing为SELINUX=disabled,执行setenforce 0临时生效;
统一建目录:执行mkdir -p /usr/local/legend/server /usr/local/legend/data,分别存服务端和数据库文件,管理更清晰。
二、各系列 Linux 环境搭建(核心差异点)
(一)CentOS 系列(以 7.x 为例)
依赖与数据库安装
装依赖:yum install -y gcc glibc-devel net-tools mariadb-server mariadb;
启数据库:systemctl start mariadb,设开机自启:systemctl enable mariadb;
初始化数据库:mysql_secure_installation,按提示设 root 密码,删匿名账号(选 “Y”)。
数据库配置(与其他系列通用步骤)
登录:mysql -u root -p,输密码进入;
建库授权:create database legend_db character set utf8; grant all on legend_db.* to 'legend_user'@'localhost' identified by '你的密码'; flush privileges;;
导数据:WinSCP 传db.sql到/usr/local/legend/data,执行mysql -u legend_user -p legend_db < /usr/local/legend/data/db.sql,输密码完成。
(二)Ubuntu 系列(以 20.04 LTS 为例)
依赖与数据库安装(包管理器差异)
先更新源:apt update;
装依赖:apt install -y gcc libc6-dev net-tools mariadb-server;
启数据库:systemctl start mariadb,设开机自启:systemctl enable mariadb;
初始化:同 CentOS,执行mysql_secure_installation,步骤一致。
(三)Debian 系列(以 11 为例)
依赖与数据库安装(适配细节)
更新源:apt update && apt upgrade -y;
装依赖:apt install -y gcc libc6-dev net-tools mariadb-server(与 Ubuntu 命令一致,但需确认依赖完整性);
启数据库:systemctl start mariadb,设自启:systemctl enable mariadb;
初始化:同前两系列,无差异。
三、Linux 各系列通用服务端部署
文件传输与解压
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。
权限设置(各系列必需)
执行:chmod +x /usr/local/legend/server/*.sh chmod +x /usr/local/legend/server/GameSrv /usr/local/legend/server/LoginSrv(Linux 权限严格,不设会启动失败)。
配置文件修改(通用步骤)
改 IP 和端口:vi /usr/local/legend/server/Config/ServerInfo.conf,按i编辑,ServerIP设为公网 IP,ServerPort设 7000(默认未占用),Esc+:wq保存;
调游戏参数:vi /usr/local/legend/server/Config/GameConfig.conf,改经验倍率(如ExpRate=5)、金币掉落率(GoldRate=3),保存方式同上。
启动服务端(通用命令)
后台启动:nohup /usr/local/legend/server/StartServer.sh &(关闭远程工具不中断进程);
验证:ps aux | grep GameSrv,显示GameSrv和LoginSrv进程即成功;若缺库(如libstdc++.so.6),CentOS 用yum install -y libstdc++,Ubuntu/Debian 用apt install -y libstdc++6。
四、登录器适配与各系列网络配置
登录器生成(通用)
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(firewalld):firewall-cmd --zone=public --add-port=7000/tcp --permanent firewall-cmd --reload,验证:firewall-cmd --query-port=7000/tcp(显 “yes”);
Ubuntu/Debian(ufw):先启用 ufw:ufw enable,再开放端口:ufw allow 7000/tcp,验证:ufw status(显 7000/tcp 允许)。
五、各系列通用常见问题解决
服务端进程秒消失
查日志:cat nohup.out,若显 “数据库连接失败”,核对ServerInfo.conf中数据库账号密码;若显 “权限不足”,重新执行chmod +x命令。
客户端连不上服务器
排查:① 查端口监听:netstat -tuln | grep 7000(显0.0.0.0:7000即正常);② 查公网 IP:curl ifconfig.me(确认与配置一致);③ 云服务器需在控制台安全组开放 7000 端口(各厂商通用)。
游戏内中文乱码
改编码:echo "export LANG=en_US.UTF-8" >> /etc/profile source /etc/profile,重启服务端:pkill GameSrv nohup /usr/local/legend/server/StartServer.sh &。
数据库远程连接(需管理时)
授权:mysql -u root -p grant all on *.* to 'root'@'%' identified by '你的密码'; flush privileges;;
开端口:CentOS 放 3306 端口(firewall-cmd --add-port=3306/tcp --permanent),Ubuntu/Debian 放 3306(ufw allow 3306/tcp),即可用 Navicat 远程连。
Linux 各系列服务器怎么架设传奇?CentOS/Ubuntu/Debian 分步指南
来源:
作者:
点击:

