After rediscovering an old favorite in the Google Play Store, Terraria, a game I adored playing in my youth, I felt inspired to set up a server on my Proxmox server for some nostalgic gaming sessions during my downtime. To my surprise, I found that it was possible to connect to a standard desktop server using the Android version. A brief google search led me to TShock (https://github.com/Pryaxis/TShock), a community-maintained open-source Terraria server written in C# .NET 6.0, compatible with Linux, the option for plugins and better performance than the original. With this knowledge in hand, I started working on setting up my own server following these steps:
Setup a LXC Container on Proxmox
Start by creating a new LXC Container in your Proxmox Web GUI by clicking on “New CT”:
Configure the ID, the hostname and set a password, or input your SSH key to access the container later.
Select a Container template. I chose Debian 12 as I’m very familiar with Debian and like the OS, but Ubuntu does the same job fine.
I think, as Terraria is not the most disk-intensive game, an 8GB rootfs will be enough for it. Keep in mind that you can always enlarge it afterwards.
As I think the maximum player count the server will ever see will be my girlfriend and me, one CPU core and 1GB of RAM is going to handle everything with ease. Increase the values if you plan on having more players.
Setup the network config. I’ll be using a static IP. Change to DHCP if you want the easy way, but keep in mind that your server’s IP might change if you use DHCP!
Keep the default DNS settings.
Check everything on the summary page, and tick the “Start after created” checkbox if everything looks right. Proceed.
Wait for the container to boot, and you’ll see the green triangle in your VM and Container list.
Setting up the server
Now it’s time to connect to the server using your favorite SSH client and set up the TShock server. We’ll start by installing the latest .NET 6.0 version from Microsoft.
Visit: https://dotnet.microsoft.com/en-us/download/dotnet/6.0
Scroll down until you see the .NET Runtime, and click on “Package manager instructions”.
Select the Debian OS (or other if you chose another), and follow the instructions on the site https://learn.microsoft.com/de-de/dotnet/core/install/linux-debian.
The first step should be to set up the Microsoft repository, which is done by executing these commands:
|
|
Now install the .NET Runtime.
|
|
If everything finished correctly, we’re able to start setting up the TShock server. We’ll start by grabbing the latest version from the GitHub releases: https://github.com/Pryaxis/TShock/releases/. Download the Linux x64 version using wget
like this:
|
|
Unzip it to the ./server/
folder.
|
|
cd into the extracted server files and start the server.
|
|
You’ll be prompted to select a world or create a new one. As this is a new server, we create a new world by entering “n”. Then you’ll be prompted to configure the world.
Now select the world by typing the number and pressing enter.
The server is going to prompt you for some more config stuff.
When everything went well, you should see “Server started” in the output. At this point, you could connect to the server and start playing, but as soon as your SSH session goes down, the server will too. So we need to run the server in the background. To achieve that, let’s first stop the server by typing stop
in its console.
I’ll be using tmux to start the server in the background. To install tmux, run this command:
|
|
Then simply run this command to start a new session:
|
|
It opens tmux and runs the Terraria server. Select your world and enter the config values, and your server should be up running again. You can now simply press CTRL+D
to detach from the session, and your server will continue to run in the background. If you want to reconnect to the session, run this command.
|
|
Autostart the Server on Boot
To autostart the server on container boot, we’ll create a systemd service file with the following content at /etc/systemd/system/terraria.service
|
|
And a script to start the server at /root/run_terraria.sh
|
|
Dont forget to make it executable.
|
|
Now enable the systemd service, and your server should start on boot.
|
|
To enter the tmux session and control the server, simply run this command and press CTRL-D
when you are done.
|
|
If you need to modify some of the config, adjust the tmux send-keys command
in the /root/run_terraria.sh
script. Every C-m
is sending an ENTER
keystroke to the server. So, if you want to modify the player count, change the sequence to this. You’ll get the point.
|
|
Connect to the Server
As said, I’ll be using the Android version of Terraria, but the same goes for the desktop version.
If you don’t see your server in the list, add it manually using its IP and the port you configured.
Enjoy your self-hosted Terraria Server!
To learn how to use plugins and do some advanced configuration, see the TShock wiki: https://ikebukuro.tshock.co/#/