In this Episode you will learn how to setup Dedicated Terraria tModLoader server with Mods!
This server will be hosted on ubuntu headless.
I have made a quick guide for this setup.
My installation is done with Hetzner CPX11 22.04 Ubuntu.
My VM is only for Terraria server usage, currently named flowerfield.
2 VCPU & 2 GB RAM is more than enough for 6 players. You can adjust your server for your needs.
Get tModLoader via github: https://github.com/tModLoader/tModLoader/releases
I will be using version v2022.09.47.50.
mkdir tModLoader cd tModLoader wget https://github.com/tModLoader/tModLoader/releases/download/v2022.09.47.50/tModLoader.zip unzip tModloader.zip chmod +x start-tModLoaderServer.sh
We are gonna change the “start-tModLoaderServer.sh” launch script as shown, so it wont ask for “Use Steam server Y/N?”. This will help later with systemd launch script.
#!/usr/bin/env bash cd "$(dirname "$0")" || exit launch_args="-server" # Use serverconfig.txt as config if not already specified if ! [[ "$launch_args" == *"-config"* ]] then launch_args="$launch_args -config serverconfig.txt" fi chmod +x ./LaunchUtils/ScriptCaller.sh ./LaunchUtils/ScriptCaller.sh $launch_args
ctrl + x + y to save nano
Now we can test if the server starts up
It should start running initial setup and when finished it should show “Choose World:”
For my test, i will create new small world and all defaults:
Your server is now ready to go! If you don’t want to use any mods but that’s no fun. Continue…
Up and running, let’s get to modding
- We can import mods from your client computer by copy pasting.
- We can also download mods from the Terraria server launcher by pressing B and giving the mod name but first we will need steam workshop / steamcmd to be installed.
I will continue by copying my client mods and transfer them to my server via WinSCP.
If you already have downloaded mods in tModLoader you can choose “Open Mods Folder” as shown in picture:
Then copy the mod files into your servers Mods folder:
Use the latest found folder for the mod from your Steam Terraria folder path
You will need to write down all of the mods you want to enable into “enabled.json” file as shown:
[ "CalamityMod", "CalamityModMusic", "MagicStorage" ]
If you now launch the server you can use Mods Menu “m” to see if the mods are activated or not:
Everything should look normal and mods active! Now we get to testing!!
If you have a brand new server with firewall activated you might want to apply access for port 7777.
ufw allow 7777
Let’s join into multiplayer with your server IP-address and see if Mods are going to get activated!
I like to specify my World folder location into serverconfig.txt so i wont loss them into default locations.
serverconfig.txt world=/home/jekku/tModLoader/Worlds/oven.wld autocreate=3 worldname=oven worldpath=/home/jekku/tModLoader/Worlds Not working: ?modpath=/home/jekku/tModLoader/Mods?
To automate it all
We will be running screen session with systemd to use tModLoader server as Jekku (User)
Create a new systemd file:
sudo nano /etc/systemd/system/tmod.service
Insert into tmod.service, Modify <user> to your own username (3 times):
[Unit] Description=server daemon for terraria [Service] Type=forking User=<user> Restart=on-failure RestartSec=10 KillMode=none ExecStart=/usr/bin/screen -dmS <user> /bin/bash -c "/home/<user>/tModLoader/start-tModLoaderServer.sh" ExecStop=/usr/local/bin/terrariad exit [Install] WantedBy=multi-user.target
This will use screen sessions to be also able to administrate the Terraria server session and use commands.
We can test this by running and also enable to it to run at server start / reboot.
sudo systemctl daemon-reload sudo systemctl start tmod.service sudo systemctl status tmod.service sudo systemctl enable tmod.service
New screen session should be seen.
We can see available screen session with:
screen -ls screen -r ID (this will connect to the running screen session)
We can see from here that the server is up and running.
You can type in commands if you like to.
ctrl + a + d to exit screen session without terminating
You can now also Start / Stop the server with systemctl:
sudo systemctl start tmod.service sudo systemctl restart tmod.service sudo systemctl stop tmod.service
You can also make the server to reboot if you want via crontab:
Reboots tmod.service everyday at 6am.
crontab -e 0 6 * * * sudo systemctl restart tmod.service
Now the server is up and running in the background and you are able to close your SSH session.