- How to Setup a Terraria Linux Server
- Does Terraria support Linux?
- Before You Begin
- Configure a Firewall for Terraria
- Firewalld
- iptables
- Install and Configure Terraria on Linux
- Managing the Terraria Service
- Screen
- systemd
- Create a Script for Basic Terraria Administration
- Running Terraria Linux Server
- Start and Enable the Terraria Server
- Server Status
- Stop the Server
- Attach to the Console
- How do I host a Terraria Server for free?
- How do I find my server port for Terraria?
- More Information
- Terraria Server with TShock on Linux
- Prerequisites
- Security
- Basic setup
- Creating a user
- Installing packages
- Installing TShock
- Starting TShock for the first time
- Running your server
- Closing notes
How to Setup a Terraria Linux Server
Terraria is a two-dimensional sandbox game, similar to Minecraft, which allows players to explore, build, and battle in an open world.
Does Terraria support Linux?
In 2015, the Terraria developers announced support for Linux, which means that players can host their own standalone Terraria servers.
This guide outlines the steps required to run a Terraria server for yourself and others to play on. These steps are compatible with any Linux distribution that uses systemd. This includes recent versions of CentOS, Debian and Ubuntu, Arch Linux and Fedora.
Due to Terraria’s system requirements, a Linode with at least two CPU cores and adequate RAM is required. For this reason, we recommend using our 4GB plan or higher when following this guide. If your Linode does not meet Terraria’s minimum requirements, the process will crash intermittently.
Before You Begin
Familiarize yourself with our Getting Started guide and complete the steps for setting your Linode’s hostname and timezone.
This guide will use sudo wherever possible. Complete the sections of our Securing Your Server guide to create a standard user account, harden SSH access and remove unnecessary network services. Do not follow the Configuring a Firewall section in the Securing Your Server Guide–we will configure the firewall for a Terraria server in the next section.
Update your operating system’s packages.
Configure a Firewall for Terraria
Firewalld
Firewalld is the default iptables controller in CentOS 7+ and Fedora. See our guide on using firewalld for more information.
Enable and start firewalld:
You should be using the public zone by default. Verify with:
Create a firewalld service file for Terraria:
Enable the firewalld service, reload firewalld and verify that the Terraria service is being used:
The output of the last command should be similar to:
UFW (Uncomplicated Firewall) is an iptables controller packaged with Ubuntu, but it’s not installed in Debian by default.
If needed, install UFW:
Add SSH and a rule for Terraria. It’s important you add rules before enabling UFW. If you don’t, you’ll terminate your SSH session and will need to access your Linode using Lish:
After your rules are added, enable UFW. Next, remove the Terraria rule for IPv6 since it’s not needed:
iptables
To manually configure iptables without using a controller, see our iptables guide for a general ruleset.
You’ll also want to add the rule below for Terraria:
Install and Configure Terraria on Linux
Download the Terraria tarball. You’ll need to check Terraria’s website for the current release version. Right-click and copy the link to use with curl or wget . We’ll use 1.4.2.3 as an example in this guide:
You will need the unzip utility to decompress the .zip file. Install it using your distribution’s package manager:
Debian/Ubuntu:
CentOS:
Extract the archive:
The Terraria Server file will contain an executable that must have have execute permissions set to run the server. Enter the following command to do this:
Terraria can be set up with a server configuration file that you can edit with options such as automatic world creation, server passwords, difficulty, and other options. You can create a basic server configuration file now to configure your server before it launches.
The options below will automatically create and serve the world MyWorld when the game server starts up. Note that you should change MyWorld to a world name of your choice.
Managing the Terraria Service
Screen
Terraria runs an interactive console as part of its server process. While useful, accessing this console can be challenging when operating game servers under service managers. The problem can be solved by running Terraria in a screen session that will enable you to send arbitrary commands to the listening admin console within Screen.
Install Screen with the system’s package manager:
CentOS:
Debian/Ubuntu:
systemd
It’s useful to have an automated way to start, stop, and bring up Terraria on boot. This is important if the system restarts unexpectedly.
Create the following file to define the terraria systemd service, replacing example_user with your limited username:
ExecStart instructs systemd to spawn a screen session containing the 64-bit TerrariaServer binary, which starts the daemon. KillMode=none is used to ensure that systemd does not prematurely kill the server before it has had a chance to save and shut down gracefully.
ExecStop calls a script to send the exit command to Terraria, which tell the server to ensure that the world is saved before shutting down. In the next section, we’ll create a script which will send the necessary commands to the running Terraria server.
Create a Script for Basic Terraria Administration
The Terraria administration script needs two primary functions:
- Attaching to the running screen session, which offers a helpful administration console.
- The ability to broadcast input into the screen session so the script can be run to save the world, exit the server, etc.
- Attach to the console for direct administration, and
- Send the console commands like save or exit while it’s running without needing to attach at all (useful when services like systemd need to send server commands).
- Press N followed by Enter for a new world.
- Choose the size that you would like.
- Type a (short) name for your world, followed by Enter.
- Choose your newly generated world by pressing 1, followed by Enter.
- Enter a port to listen on, or just press Enter to use the default Terraria port 7777.
- Go to Multiplayer -> Join .
- Select or create a character.
- Enter the IP of your Vultr server.
- For the server port, use the default 7777 or the port configured on your server.
- In your game window, press Enter.
- Type /auth XXXXXXX replacing XXXXXXX with the authentication code displayed when your server was started.
- Press Enter in your game window.
- Type /user add
- Press Enter again and log in using /login username password .
- If this all works correctly, you can confirm everything with /auth-verify .
- Press Escape.
- Go to «Settings».
- Select «Save & Exit».
- Press 1 followed by Enter to select your world.
- Enter a port or press Enter to use the default port of 7777.
- Press Ctrl + A.
- Press D.
Create a terrariad file, enter the following script, then save and close:
Verify that you can execute the script:
This script permits you to both:
Running Terraria Linux Server
Start and Enable the Terraria Server
Now that the game server is installed, the scripts are written, and the service is ready, the server can be started with a single command:
The first time you run the server, it will generate the world defined earlier. This will take a while, so give it time before trying to connect. To watch the world generation progress, use:
In addition to starting and stopping the terraria service, systemd can also use the service file created earlier to automatically start Terraria on boot.
To enable the service at startup:
If the operating system is restarted for any reason, Terraria will launch itself on reboot.
Server Status
To check if the server is running, use the command:
The output should be similar to:
Stop the Server
If you ever need to shut down Terraria, use the following command to save the world and shut down the game server:
Attach to the Console
In the course of running your server, you may need to attach to the console to do things like kick players or change the message of the day (MOTD). To enter the Terraria server console with the terrariad script use:
Type help to get a list of commands. Once you’re done, use the keyboard shortcut CTRL+A then D to detach from the screen session and leave it running in the background. More keyboard shortcuts for Screen can be found in the Screen default key bindings documentation.
How do I host a Terraria Server for free?
To host a Terraria server for free, choose a free plan first and then choose the country where you are planning to host this Terraria server.
How do I find my server port for Terraria?
Default server port for Terraria is 7777. But if you have port forwarding enabled, your server port is your IP address + Colin + the port number.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on Monday, December 21, 2015.
Источник
Terraria Server with TShock on Linux
Terraria is a MMORPG based on mining, building, and fighting. Some people say its a 2D version of Minecraft, but that wouldn’t do justice to Terraria’s offerings — not by a long shot.
In this guide, I’ll show you step by step how to make a Terraria server with TShock on Linux. You could even setup multiple Terraria servers.
Some basic Linux knowledge is recommended. At the very least, you should understand how to use SSH.
By the end of the tutorial, you will be able to invite friends over to join your epic quests.
Prerequisites
This tutorial is based on Ubuntu 14.10, but more recent Ubuntu or Debian flavors will work. For other Linux versions, the package names may differ but most of the steps and configuration will be the same.
We will start off with a new Ubuntu 14.10 server on Vultr.
Terraria uses quite a bit of memory, especially for large worlds. For instance, a Vultr server with 1024MB RAM will only support a small world with a few players.
Security
A clean Ubuntu-based image on Vultr starts with access to basic services. Only NTP and SSH ports are opened. If you want to host other services, then you might want to secure your incoming traffic and move your SSH port to something other than the default port.
This guide doesn’t cover all the changes needed to secure your server — there are other guides on Vultr Docs for that. Remember, Terraria uses TCP port 7777 by default.
Basic setup
We’ll create a basic user to run the Terraria server, since we don’t want to run the server as root. After that, we’ll install the necessary packages.
Creating a user
Log in to your server as root and create a new user for your Terraria server. You may receive some error messages about missing locales. Ignore those for now.
The system will ask for a new UNIX password. Enter a fairly secure random password and remember it (or jot it down).
Now, the system will ask for some user details. You can just press Enter to leave these empty.
When the system asks you to confirm the information («Is the information correct?»), press Y followed by Enter.
Installing packages
Terraria is a game based on the Microsoft «.NET» framework. The Linux implementation of «.NET» is called «mono». We’ll install only the necessary packages to get the game running and some support packages.
Your system is now ready to run Terraria.
Installing TShock
At this point, you need to be logged into your server as user «terraria».
Download and unzip a release of TShock. You can check the official TShock website for newer releases. The Terraria server download is included with TShock.
Starting TShock for the first time
The first time you start TShock, you must join your server to make yourself the administrator. Start the server.
The gameserver will start and show you the server version. After that, it will ask you what world you would like to start. Since this is a new server, there are no previous worlds. We’ll create a new one.
The larger the world, the more memory you’ll need. Remember, a basic Vultr server with 1024MB RAM will only support a small world.
The server will now start generating your new world. When it has finished, you’ll be back in the main selection menu.
Your world will be loaded and TShock will show you an authorization code.
TShock Notice: To become SuperAdmin, join the game and type /auth 2044111
This token will display until disabled by verification. (/auth-verify)
Write this code down and start Terraria.
Tip: Use windowed mode in Terraria so that you can switch between your SSH session and the game.
Congratulations, you’ve just entered your new world. Now it’s time to authenticate as the administrator.
The server will confirm your authentication code and display a message.
Note: If the text went away too fast, press Enter to show it again.
The server wants us to create a new admin user so that we can gain admin permissions the next time we join our server.
superadmin replacing and
with your own username and a new password.
Now that the configuration is done. We’ll shutdown the server and have it save everything.
First, disconnect your Terraria client from the server.
Now, shutdown the server. This is accomplished in your SSH session by typing «off» in the server console, then pressing Enter.
The initial configuration is now complete.
Running your server
We want the server to keep running, even when we disconnect our SSH session. So we’ll use a screen session to do so.
As the «terraria» user, start screen:
Press Enter to close the credits screen. Now, start the TShock server again.
Load your world.
You are now in the server console, for a list of commands, type «help», then press Enter. You can enter Terraria server commands in this console.
To close your SSH session and keep the server running, use the following key sequence:
You won’t get any feedback until you press the D key.
After this, your screen will be cleared and you will see output similar to the following.
You can now safely close your SSH session and the server will keep running in the background.
When you reconnect to your server, you can type the following to enter the server console again:
Closing notes
There are lots of options and things to change with the TShock server. Please read the documentation for more details. Enjoy!
Источник