7 Days to Die Wiki
(Initial guide content)
m (Fixed formatting problem)
Line 23: Line 23:
 
* You might want to create a second storage volume in which to store SteamCMD and games (leaving the root volume as the standard 8GB)
 
* You might want to create a second storage volume in which to store SteamCMD and games (leaving the root volume as the standard 8GB)
 
* At the time of this writing, a c3.xlarge instance gets your 4 vCPUs, 7.5GB of RAM, and built in Enhanced Networking for around $0.21/hour. An rc3.large is cheaper with more RAM but less CPU.
 
* At the time of this writing, a c3.xlarge instance gets your 4 vCPUs, 7.5GB of RAM, and built in Enhanced Networking for around $0.21/hour. An rc3.large is cheaper with more RAM but less CPU.
* Make a new security group and add access for the port you want to run the
+
* Make a new security group and add access for the port you want to run the game on PLUS the 2 ports after it (so if you run on 26900, your policy should allow UDP ports 26900-26902)
* game on PLUS the 2 ports after it (so if you run on 26900, your policy should allow UDP ports 26900-26902)
 
   
 
=== Bring server up to date ===
 
=== Bring server up to date ===

Revision as of 15:03, 10 January 2015

Listed below are the steps required to launch a dedicated game server on an Amazon Linux 64bit HVM EC2 instance. They do not cover any basic or general information regarding linux server administration, but they should be pretty straight forward to follow.

Note that Amazon Linux is a RedHat-like distribution, so a similar set of steps can probably be used to get a server running under Fedora, RHEL, CentOS, etc. (though you will have to have appropriate yum repositories configured and some package names may differ).

The code snippets below should all be directly paste-able into a command prompt (hence the bash comment characters and the creation of scripts using echo). There are a couple of files that will need to be edited though. The AMI should come with vim and nano, but if you prefer something else you will have to install it.
Dgmackay (talk) 14:38, 10 January 2015 (UTC)


Create EC2 instance and connect[ | ]

How to use Amazon Web Services and EC2 is beyond the scope of this document, but a few notes are given below:

  • You will want an instance with more than 6GB of RAM and enough CPU to not get bogged down as the game runs
  • You might want to create a second storage volume in which to store SteamCMD and games (leaving the root volume as the standard 8GB)
  • At the time of this writing, a c3.xlarge instance gets your 4 vCPUs, 7.5GB of RAM, and built in Enhanced Networking for around $0.21/hour. An rc3.large is cheaper with more RAM but less CPU.
  • Make a new security group and add access for the port you want to run the game on PLUS the 2 ports after it (so if you run on 26900, your policy should allow UDP ports 26900-26902)

Bring server up to date[ | ]

sudo su -l
yum update -y

Install prerequisites[ | ]

# Install SteamCMD pre-reqs
yum install -y glibc.i686 libstdc++48.i686

# Install 7 Days to Die pre-reqs
yum install -y mesa-libGLU libXcursor libXrandr

# Install virtual frame buffer
# NOTE: This is needed if you will be running in graphic mode
# (required as of this writing due to issues running with -no-graphic under
# linux)
yum install -y xorg-x11-server-Xvfb

Create a location for SteamCMD and Games[ | ]

mkdir /opt/games

# Format and mount game storage drive, if using another volume for storage
# Your device name might be something other than /dev/xvdb, so edit the lines
# accordingly
mkfs.ext4 /dev/xvdb
echo "/dev/xvdb   /opt/games  ext4    defaults,noatime  1   1" >>/etc/fstab
mount /opt/games

Create a user to run games as[ | ]

# Add a steam user and setup the home directory
adduser --home /opt/games steam
cp /etc/skel/.* /opt/games
chown -R steam:steam /opt/games

Install SteamCMD[ | ]

# Switch to steam user
su -l steam

# Create SteamCMD directory
mkdir ~/steamcmd && cd ~/steamcmd

# Download SteamCMD
wget 'http://media.steampowered.com/installer/steamcmd_linux.tar.gz'

# Unpack SteamCMD
tar -xzvf steamcmd_linux.tar.gz && rm -f steamcmd_linux.tar.gz

# Launch SteamCMD
./steamcmd.sh

# Downloads updates and all that. Once it is done, verify that logging in 
# works (and enter SteamGuard code if required)
login YOURSTEAMUSERNAME YOURSTEAMPASSWORD

# Exit interactive session
exit

Create a script to install and update 7 Days[ | ]

# Create a directory for scripts
mkdir /opt/games/bin

# Create general app installing/updating script
# (re-usable for other games)
# NOTE: You will either have to edit the YOURSTEAM lines below, or edit
# the script afterwards to put the correct username and password in
echo '#!/bin/bash' > /opt/games/bin/steamgame_update.sh
echo 'APP_ID=$1' >> /opt/games/bin/steamgame_update.sh
echo 'APP_DIR=$2' >> /opt/games/bin/steamgame_update.sh
echo 'STEAM_USER="YOURSTEAMUSERNAME"' >> /opt/games/bin/steamgame_update.sh
echo 'STEAM_PASS="YOURSTEAMPASSWORD"' >> /opt/games/bin/steamgame_update.sh
echo '/opt/games/steamcmd/steamcmd.sh +login ${STEAM_USER} ${STEAM_PASS} +force_install_dir ${APP_DIR} +app_update ${APP_ID} +exit' >> /opt/games/bin/steamgame_update.sh

# Create 7days installing/updating script
echo '#!/bin/bash' > /opt/games/bin/update_7days.sh
echo '/opt/games/bin/steamgame_update.sh 251570 /opt/games/7days' >> /opt/games/bin/update_7days.sh

# Set script permissions
chmod 750 /opt/games/bin/*.sh

# Run update script to download and install 7days
# (also used whenever you need to update the game)
/opt/games/bin/update_7days.sh

Modify server config and launch scripts[ | ]

Since our EC2 instance is 64 bit, we need to adjust the server launching script. That script should be located here: /opt/games/7days/startserver.sh

Uncomment the x86_64 start line and comment out the x86 start line, so that this:

#if [ "$(uname -m)" == "x86_64" ]; then
#       ./7DaysToDie.x86_64 -logfile 7DaysToDie_Data/output_log.txt $@
#else
        ./7DaysToDie.x86 -logfile 7DaysToDie_Data/output_log.txt $@
#fi

Becomes this:

#if [ "$(uname -m)" == "x86_64" ]; then
        ./7DaysToDie.x86_64 -logfile 7DaysToDie_Data/output_log.txt $@
#else
#       ./7DaysToDie.x86 -logfile 7DaysToDie_Data/output_log.txt $@
#fi

We will also want to set a few settings in the server config file. That file is located here: /opt/games/7days/serverconfig.xml

Things you might want to change right away:

  • ServerPort : If you want to run on something other than 26900-26902
  • ServerIsPublic : Defaults to true, should control whether you server gets listed or not
  • ServerName : Name of your server
  • ServerPassword : Password for your server, if you want it locked
  • ServerDescription : Description for your server
  • TelnetEnabled : Whether you want the console telnet accessible (recommended for use from localhost only!)
  • TelnetPassword : Password required when accessing telnet
  • SaveGameFolder : Initially commented out, you can use this option to hardcode where save files go. Make sure the director you specify exists

Initial test: can we start the game?[ | ]

In one terminal, start up Xvfb to be our "fake" graphical display

Xvfb :99 -screen 0 640x480x16

In a second terminal (start another SSH connection), launch the game and watch the log output

# Start game server
DISPLAY=:99.0 /opt/games/7days/startserver.sh -quit -batchmode -configfile=serverconfig.xml -dedicated &

# Watch the log file (the grep command weeds out some known warnings and blank lines)
tail -f /opt/games/7days/7DaysToDie_Data/output_log.txt | grep -Ev '(An invalid object handle was used|^\(Filename:|^\s*$)'

There will be some shader errors, downsize warnings, etc... but eventually you should start to see some stats periodically reported. That means the game thinks it is up! Try launching 7 Days on your computer and see if you can connect.

COMING SOON[ | ]

  • Start/Stop game as a service
  • Launch game on instance boot

See also[ | ]