Getting terraria right from the start saves hours of debugging later. In this comprehensive guide, we'll cover everything from initial setup to production-ready configuration, including tshock and admin considerations.
Prerequisites
- Basic familiarity with the Linux command line
- Root or sudo access to the server
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
Server Installation
When scaling this setup, consider vertical scaling (adding more RAM/CPU) first, as it's simpler to implement. Horizontal scaling adds complexity but may be necessary for high-traffic applications.
# Create a dedicated game server user
sudo useradd -m -s /bin/bash gameserver
sudo su - gameserver
# Install SteamCMD
mkdir -p ~/steamcmd && cd ~/steamcmd
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
# Install the game server
./steamcmd.sh +force_install_dir ~/servers/terraria +login anonymous +app_update 1234567 validate +quit
The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.
- Test your backup restore procedure monthly
- Review log files weekly for anomalies
- Keep your system packages updated regularly
- Monitor disk space usage and set up alerts
- Enable automatic security updates for critical patches
Configuration File Setup
Security should be a primary consideration when configuring terraria. Always use strong passwords, keep software updated, and restrict network access to only the necessary ports and IP addresses.
# Server configuration file
[Server]
ServerName=My terraria Server
MaxPlayers=32
ServerPort=27015
Password=
AdminPassword=changeme
SaveInterval=300
The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.
Firewall and Port Configuration
For production deployments, consider implementing high availability by running multiple instances behind a load balancer. This approach provides both redundancy and improved performance under heavy load.
# Create systemd service for auto-start
sudo tee /etc/systemd/system/terraria.service << 'EOF'
[Unit]
Description=terraria Dedicated Server
After=network.target
[Service]
User=gameserver
WorkingDirectory=/home/gameserver/servers/terraria
ExecStart=/home/gameserver/servers/terraria/start.sh
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable terraria
sudo systemctl start terraria
The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.
Performance Considerations
The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.
Common Issues and Solutions
- Permission denied errors: Ensure files and directories have the correct ownership. Use
chown -Rto fix ownership andchmodfor permissions. - Slow performance: Check for disk I/O bottlenecks with
iostat -x 1and network issues withmtr. Review application logs for slow queries or requests. - Service won't start: Check the logs with
journalctl -xe -u terraria. Common causes include port conflicts, missing configuration files, or insufficient permissions.
Wrapping Up
Following this guide, your terraria setup should be production-ready. Keep an eye on resource usage as your traffic grows and don't forget to test your backup and recovery procedures periodically.