用VPS/Linux/CentOS7搭建泰拉瑞亚原版/mod服务器教程

1.准备服务器/配置swap

选择服务器
我选的是腾讯云学生服务器,一个月十块钱的,系统选择centOS7.6,64位,设置密码,这个密码就是ssh的时候用的密码

Windows用PuTTy/macOS用自带的终端连接服务器
ssh root@你的ip
在输入密码的时候是没有显示的,正常输入完点回车就行

检查swap是否够1G,如果够则跳过这一步
free -m

删除swap分区
swapoff -a

新增分区
dd if=/dev/zero of=/root/swapfile bs=1M count=1024

格式化分区
mkswap /root/swapfile

启动分区
swapon /root/swapfile

开机自启
nano /etc/fstab,最下面添加/root/swapfile swap swap defaults 0 0

重启
reboot

2.搭建游戏,root用户登陆

安装需要的软件
yum install wget -y
yum install screen -y
yum install unzip -y

开放防火墙
firewall-cmd --permanent --add-port=7777/tcp
firewall-cmd --reload

建立游戏文件夹
cd /opt/
mkdir terraria
mkdir terraria/{bin,downloads}

下载服务端,版本1353
cd /opt/terraria/downloads
wget http://terraria.org/server/terraria-server-1353.zip

解压
unzip terraria-server-1353.zip -d /opt/terraria/bin

设定服务器设置
cp -p Windows/serverconfig.txt /opt/terraria/
cd /opt/terraria/
nano serverconfig.txt

在打开的nano页面最下面写入
world=/opt/terraria/Worlds/世界的名字.wld
autocreate=2
worldname=世界的名字
difficulty=0
maxplayers=4
password=设定一个密码
worldpath=/opt/terraria/Worlds

名字和密码自定

启动服务器
./TerrariaServer.bin.x86_64 -config /opt/terraria/serverconfig.txt
初次运行需要时间,耐性等待
运行成功后输入
exit
退出服务器

重新编辑配置文件保证自动化运行
cd /opt/terraria
cp -p serverconfig.txt serverconfig.txt_yyyymmdd
nano serverconfig.txt
在autocreate,worldname,difficult前添加#改为
#autocreate=2
#worldname=Terraria
#difficulty=1

3.制作自动启动脚本

cd /opt/terraria
nano terra_script.sh

在打开的nano窗口输入
#!/bin/bash

USERNAME=‘root’
SCNAME=‘root’
TERA_VER=‘1353’
BIN_PATH="/opt/terraria/bin/$TERA_VER/Linux/"
SERVICE=‘TerrariaServer.bin.x86_64’
CONFIG=’/opt/terraria/serverconfig.txt’

ME=whoami

if [ $ME != $USERNAME ] ; then
echo “Please run the $USERNAME user.”
exit
fi

start() {
if pgrep -u $USERNAME -f S E R V I C E > / d e v / n u

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值