User Tools

Site Tools


esxi:terraria_server

Table of Contents

Terraria Server

Setup and run a Terraria game server in Photon OS on ESXi.

Setup

First, install a base installation of Photon OS with the following changes:

  • Hostname: Photon-Terraria
  • CPU:
    • CPU: 2
    • Cores per Socket: 2
  • Memory: 2GB

Setup minimal installed profile of PhotonOS

  • Download the Photon OS OVA with virtual hardware v13 from https://github.com/vmware/photon/wiki/Downloading-Photon-OS
  • In ESXi:
    • Create/Register VM:
      • Deploy a virtual machine from an OVF or OVA file
      • Name the VM
      • Upload the Photon OS OVA file
      • Specify the desired Target Datastore
      • Accept the License Agreement
      • Deselect Power on automatically
      • Confirm settings and Finish
    • Wait for the files to upload
    • If autostart is desired for this machine go to Host > Manage > System > Autostart:
      • Click on the current VM
      • Enable
      • Use Start earlier and Start later to set the desired order
    • Go to Virtual Machines on the sidebar and click on the current VM
    • Actions > Edit Settings:
      • CPU > Enable Expose hardware assisted virtualization to the guest OS
      • If using NVMe storage for the datastore:
        • Add other device > NVMe controller
        • Hard Disk 1 > Controller location > NVMe controller 0
        • Save and reopen Edit Settings
        • Remove SCSI controller 0
      • NOTE: Disable Secure Boot because of an issue after updating, see Issue #974
      • Select other appropriate VM settings depending on desired applications
    • Power on the VM, then shut it down again to generate a MAC address
    • Give the VM a static IP address from your router using the generated MAC address (found under Hardware Configuration > Network adapter 1) and desired hostname
    • Power on the VM
    • Using an SSH client, connect to the hostname set above, then run:
# Login with root details from the VM note
# Follow instructions to set new password
# Update packages:
tdnf upgrade
# Disable password expiry:
chage -M -1 root
# Set new hostname:
hostnamectl set-hostname <hostname-as-set-in-router>
# Set the timezone to Perth
ln -sf /usr/share/zoneinfo/Australia/Perth /etc/localtime
# Change the SSH port to 50001:
sed -i "s/#Port 22/Port 50001/" /etc/ssh/sshd_config
sed -i "s/-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT/-A INPUT -p tcp -m tcp --dport 50001 -m state --state NEW -j ACCEPT/" /etc/systemd/scripts/ip4save
exit
  • Shutdown the VM
  • Edit VM note to be the following:
Minimal installed profile of PhotonOS
User: root

Ports:
50001/tcp SSH
  • Save a snapshot called Base Install
2020/05/18 18:24 · derek

Install Terraria Server:

  • Add a port forwarding rule in your router for tcp and udp port 7777 to the IP of the VM
  • Using an SSH client, connect to <hostname>:50001 then run:
# Allow port 7777 through iptables
sed -i "s/COMMIT/-A INPUT -p tcp -m tcp --dport 7777 -j ACCEPT\n-A INPUT -p udp -m udp --dport 7777 -j ACCEPT\nCOMMIT/" /etc/systemd/scripts/ip4save
reboot  # And then reconnect the SSH client
 
tdnf install unzip tmux less
 
# Download and place the server in /terraria (Check the PC Dedicated Server link at the bottom of https://terraria.org for the latest server file and change all the "1402" references to the correct version)
cd /tmp
curl --output terraria-server.zip https://terraria.org/system/dedicated_servers/archives/000/000/036/original/terraria-server-1402.zip?1589675482
unzip terraria-server.zip
mv 1402/Linux /terraria/server
 
# Remove temp files
rm terraria-server.zip
rm -r 1402
 
# Allow the server to be executed and set the config
chmod u+x /terraria/server/TerrariaServer*
 
vim /terraria/serverconfig.txt
# Press i, then paste the following into the window (replacing the password):
autocreate=2
worldname=World
difficulty=2
maxplayers=16
port=7777
password=password1234
worldpath=/terraria/worlds/
##
<esc> :wq
 
# Start the server
tmux new -s terraria "/terraria/server/TerrariaServer.bin.x86_64 -config /terraria/serverconfig.txt" \; pipe-pane -o -t terraria "cat >>/terraria/server.log"
  • Either use <Ctrl+b> d to detach the tmux client, or use the -d flag in the tmux command to start it disconnected.
  • Either re-attach to the session with tmux a -t terraria, and type exit, or run tmux send-keys -t terraria "exit" Enter to shutdown the server.
  • Edit the VM note and append the following:
7777/both Terraria (Port Forwarded)

Run with:
tmux new -d -s terraria "/terraria/server/TerrariaServer.bin.x86_64 -config /terraria/serverconfig.txt" \; pipe-pane -o -t terraria "cat >>/terraria/server.log"

Stop with:
tmux send-keys -t terraria "exit" Enter

Attach tmux client:
tmux a -t terraria
Detach tmux client:
<Ctrl+b> d

Update

  • If desired, Log in to ESXi, navigate to the docker VM and create new snapshot
  • Using an SSH client, connect to <hostname>:50001 then run:
tdnf upgrade
tdnf clean all
reboot  # If desired/needed
2020/05/18 18:24 · derek
  • Check the PC Dedicated Server link at the bottom of https://terraria.org for the latest server file and change all the 1402 references to the correct version and link
# Download
cd /tmp
curl --output terraria-server.zip https://terraria.org/system/dedicated_servers/archives/000/000/036/original/terraria-server-1402.zip?1589675482
unzip terraria-server.zip
 
# Stop the server
tmux send-keys -t terraria "exit" Enter
 
# Replace server files FIXME
rm -r /terraria/server
mv 1402/Linux /terraria/server
chmod u+x /terraria/server/TerrariaServer*
 
# Remove temp files
rm terraria-server.zip
rm -r 1402
 
# Start the server
tmux new -d -s terraria "/terraria/server/TerrariaServer.bin.x86_64 -config /terraria/serverconfig.txt" \; pipe-pane -o -t terraria "cat >>/terraria/server.log"
 
exit
esxi/terraria_server.txt · Last modified: 2020/07/03 18:37 by derek