In this guide, I’ll show you step by step how to make a Terraria server with TShock on Linux. You could even setup multiple Terraria servers.
Some basic Linux knowledge is recommended. At the very least, you should understand how to use SSH.
By the end of the tutorial, you will be able to invite friends over to join your epic quests.
This tutorial is based on Ubuntu 14.10, but more recent Ubuntu or Debian flavors will work. For other Linux versions, the package names may differ but most of the steps and configuration will be the same.
We will start off with a new Ubuntu 14.10 server on Aklwebhost.
Terraria uses quite a bit of memory, especially for large worlds. For instance, a Aklwebhost server with 1024MB RAM will only support a small world with a few players.
A clean Ubuntu-based image on Aklwebhost starts with access to basic services. Only NTP and SSH ports are opened. If you want to host other services, then you might want to secure your incoming traffic and move your SSH port to something other than the default port.
This guide doesn’t cover all the changes needed to secure your server – there are other guides on Aklwebhost Docs for that. Remember, Terraria uses TCP port 7777 by default.
We’ll create a basic user to run the Terraria server, since we don’t want to run the server as root. After that, we’ll install the necessary packages.
Log in to your server as root and create a new user for your Terraria server. You may receive some error messages about missing locales. Ignore those for now.
adduser terraria
The system will ask for a new UNIX password. Enter a fairly secure random password and remember it (or jot it down).
Now, the system will ask for some user details. You can just press Enter to leave these empty.
When the system asks you to confirm the information (“Is the information correct?”), press Y followed by Enter.
Terraria is a game based on the Microsoft “.NET” framework. The Linux implementation of “.NET” is called “mono”. We’ll install only the necessary packages to get the game running and some support packages.
apt-get -y install wget unzip screen \
libmono-corlib4.0-cil libmono-sqlite4.0-cil libmono-system-core4.0-cil libmono-system-net4.0-cil \
libmono-system-runtime4.0-cil mono-runtime mono-runtime-sgen libmono-corlib4.0-cil \
libmono-sqlite4.0-cil libmono-system-core4.0-cil libmono-system-net4.0-cil \
libmono-system-runtime4.0-cil mono-runtime mono-runtime-sgen libmono-data-tds4.0-cil \
libmysql6.4-cil libmono-system-runtime-serialization4.0-cil \
libmono-system-runtime-serialization-formatters-soap4.0-cil libmono-system-data-linq4.0-cil \
libmono-system-xml-linq4.0-cil libmono-system-xml-serialization4.0-cil libmono-system-xml4.0-cil
Your system is now ready to run Terraria.
At this point, you need to be logged into your server as user “terraria”.
su terraria
Download and unzip a release of TShock. You can check the official TShock website for newer releases. The Terraria server download is included with TShock.
wget -O tshock.zip 'https://github.com/NyxStudios/TShock/releases/download/v4.2.9/tshock_4.2.9.zip'
unzip tshock.zip -d ~/tshock
The first time you start TShock, you must join your server to make yourself the administrator. Start the server.
cd ~/tshock
mono TerrariaServer.exe
The gameserver will start and show you the server version. After that, it will ask you what world you would like to start. Since this is a new server, there are no previous worlds. We’ll create a new one.
The larger the world, the more memory you’ll need. Remember, a basic Aklwebhost server with 1024MB RAM will only support a small world.
The server will now start generating your new world. When it has finished, you’ll be back in the main selection menu.
Your world will be loaded and TShock will show you an authorization code.
TShock Notice: To become SuperAdmin, join the game and type /auth 2044111
This token will display until disabled by verification. (/auth-verify)
Write this code down and start Terraria.
Tip: Use windowed mode in Terraria so that you can switch between your SSH session and the game.
Multiplayer -> Join
.Congratulations, you’ve just entered your new world. Now it’s time to authenticate as the administrator.
/auth XXXXXXX
replacing XXXXXXX
with the authentication code displayed when your server was started.The server will confirm your authentication code and display a message.
You are now superadmin, please do the following to finish your install:
/user add <username> <password> superadmin
Creates: <username> with the password <password> as part of the superadmin
group.
Please use /login <username> <password> to login from now on.
If you understand, please /login <username <password> now, and type
/auth-verify
Note: If the text went away too fast, press Enter to show it again.
The server wants us to create a new admin user so that we can gain admin permissions the next time we join our server.
/user add <username> <password> superadmin
replacing <username>
and <password>
with your own username and a new password./login username password
./auth-verify
.Now that the configuration is done. We’ll shutdown the server and have it save everything.
First, disconnect your Terraria client from the server.
Now, shutdown the server. This is accomplished in your SSH session by typing “off” in the server console, then pressing Enter.
The initial configuration is now complete.
We want the server to keep running, even when we disconnect our SSH session. So we’ll use a screen
session to do so.
As the “terraria” user, start screen:
screen
Press Enter to close the credits screen. Now, start the TShock server again.
cd ~/tshock
mono TerrariaServer.exe
Load your world.
You are now in the server console, for a list of commands, type “help”, then press Enter. You can enter Terraria server commands in this console.
To close your SSH session and keep the server running, use the following key sequence:
You won’t get any feedback until you press the D key.
After this, your screen will be cleared and you will see output similar to the following.
[detached from 1298.pts-2.aklwebhost]
You can now safely close your SSH session and the server will keep running in the background.
When you reconnect to your server, you can type the following to enter the server console again:
screen -r
There are lots of options and things to change with the TShock server. Please read the documentation for more details. Enjoy!
]]># Secure Iptables
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# Teamspeak
iptables -I INPUT -p udp --dport 9987 -j ACCEPT
iptables -I INPUT -p udp --sport 9987 -j ACCEPT
iptables -I INPUT -p tcp --dport 30033 -j ACCEPT
iptables -I INPUT -p tcp --sport 30033 -j ACCEPT
iptables -I INPUT -p tcp --dport 10011 -j ACCEPT
iptables -I INPUT -p tcp --sport 10011 -j ACCEPT
# HTTP(s)
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --sport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p tcp --sport 443 -j ACCEPT
# SSH
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
iptables -I INPUT -p tcp --sport 22 -j ACCEPT
# DNS
iptables -I INPUT -p udp --dport 53 -j ACCEPT
iptables -I INPUT -p udp --sport 53 -j ACCEPT
service iptables save && service iptables restart
# Update system
yum -y update
# Add Teamspeak user
useradd teamspeak
# Download, unzip and cleanup Teamspeak
cd /home/teamspeak
wget http://ftp.4players.de/pub/hosted/ts3/releases/3.0.7.1/teamspeak3-server_linux-amd64-3.0.7.1.tar.gz
tar xvfz teamspeak3-server_linux-amd64-3.0.7.1.tar.gz
mv teamspeak3-server_linux-amd64/* `pwd`
rm -rf teamspeak3-server_linux-amd64 && rm -rf teamspeak3-server_linux-amd64-3.0.7.1.tar.gz
# Add chkconfig support to startup file and link to binary
sed -i 's/# All rights reserved/# All rights reserved\n# chkconfig: 2345 99 00/g' ts3server_startscript.sh
ln -s /home/teamspeak/ts3server_startscript.sh /etc/init.d/teamspeak
# Change permissions of Teamspeak
chown -R teamspeak:teamspeak /home/teamspeak
chown -R teamspeak:teamspeak /etc/init.d/teamspeak
# Remount shared memory
mount -t tmpfs tmpfs /dev/shm
# Change to Teamspeak user and run server
su teamspeak
./ts3server_startscript.sh start
echo "Your Teamspeak URL is: `curl ipv4.icanhazip.com`"
]]>You will need “screen” to keep the server running when you exit your SSH client (such as PuTTY). Installing “screen” is simple and only requires you to perform one command.
yum install -y screen
Create a new directory and retrieve the SA-MP software. The “wget” below uses the latest version from the time this article was posted. You may visit the official site to check for newer releases.
cd /
mkdir samp-server
wget http://team.sa-mp.com/files/samp03dsvr_R2.tar.gz
Extract the “tar” file.
tar -zxf samp037svr_R2.tar.gz
Enter the “samp03” folder and edit the configuration file. Make any configuration changes that you would like during this step.
cd samp03
vi server.cfg
This is the easy part. First, we must open up a “screen” session. You can change “server” to any name you’d like for easier access back to the “screen” session.
screen -S server
Start the SA-MP server.
./samp03svr
At this point, the server is running. You may leave it running and detach from your screen session by pressing Ctrl+A, then D.
If you require access to the server console again, you can return to the screen with the following command. Update the “server” string if you changed it earlier.
screen -r server
Congratulations! You have installed and started an SA-MP server.
]]>Before we can setup the Insurgency server, we need to install a few other packages. Follow the steps below.
sudo apt-get install lib32gcc1
useradd -m steam
su - steam
mkdir steamcmd
cd steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
./steamcmd.sh
login anonymous
force_install_dir ./insurgency/
app_update 237410
quit
cd insurgency
screen ./srcds_linux
Congratulations! You now have an Insurgency game server all setup and running. You can connect to it by using the IP address allocated to your Aklweb host server.
If you received an error on executing the startup script, try running the following command first:
export LD_LIBRARY_PATH=/home/steam/steamcmd/insurgency/bin
There are many configuration options for Insurgency. See this guide for configuration reference.
]]>It is very important that you have the multilib
repository enabled if and only if you are on a 64-bit (amd64) server. If it isn’t enabled, then SteamCMD cannot run and you cannot even download the server files. To do this, you must uncomment the following lines in /etc/pacman.conf
.
[multilib]
Include = /etc/pacman.d/mirrorlist
If you are on 32-bit (i686) Arch, you can safely ignore this.
There is an AUR package for SteamCMD and it is one of the easiest ways to install SteamCMD on Arch. There are a couple odd things about it though:
/usr/share/steamcmd
.If you are on a 64-bit server, you must install the package lib32-gcc-libs
.
sudo pacman -Sy lib32-gcc-libs
Now we must build the package. Using curl, download the tarball for the package.
curl -O http://media.steampowered.com/installer/steamcmd_linux.tar.gz
Once the download finishes, extract and change to the directory created.
tar -xvzf steamcmd.tar.gz
cd steamcmd
Now, using makepkg, build the package.
makepkg -ci
If you didn’t pass the -i
flag to the makepkg command, use pacman to install it.
sudo pacman -U *.pkg.tar.xz
You now have SteamCMD installed and ready to download Team Fortress 2 server.
This guide uses a separate user to run the server, so we will create a new tf2 user and group with it’s own home folder in /var/lib
.
sudo groupadd tf2
sudo mkdir /var/lib/tf2
sudo useradd -d /var/lib/tf2 -g tf2 -s /bin/bash tf2
sudo chown tf2.tf2 -R /var/lib/tf2
Now to install the server.
sudo -u tf2 steamcmd +login anonymous +force_install_dir ~tf2/server +app_update 232250 validate +quit
Once that finishes downloading, you have the server installed.
Although you can run the server, some configuration should be done so that the server isn’t too generic. The main file that we put settings in is the server.cfg
file. Below is a very basic server.cfg
file.
To open/create the file, use your favorite editor. Here vim is used, but you can use any text editor like nano.
sudo -u tf2 vim ~tf2/server/tf/cfg/server.cfg
Add the following. More settings can be found on the Team Fortress 2 wiki and Valve developer page. Be sure to change some of the settings to suit your needs.
hostname "Server Name"
rcon_password "password"
sv_password ""
sv_contact "email@example.com"
sv_tags ""
sv_region "255"
sv_lan "0"
exec banned_user.cfg
exec banned_ip.cfg
writeid
writeip
It is known that you need a multiplexer like GNU Screen or tmux to run your server unattended. Here we are going to use tmux to run the server, but if you prefer and know how to use screen, feel free to use it.
Install tmux by using pacman.
sudo pacman -Sy tmux
You can start the server with the following command. You can change the map and maxplayers if desired.
sudo -u tf2 tmux new-session -d -s tf2-console -d '~tf2/server/srcds_run -console -game tf +map cp_dustbowl +maxplayers 24'
If you ever need to attach to the console, run the following.
sudo -u tf2 tmux attach -t tf2-console
You can leave the server console by typing CTRL + B then releasing those keys and then pressing D.
Running the server with systemd is convenient for many reasons. The main one is that you can have it start when the VPS starts. This requires a script and a systemd unit to be written. Even though this is a good idea, it is optional.
The first thing to write is the start script. To create the script, use your favorite editor. Here vim is used, but you can use any text editor like nano.
sudo -u tf2 vim ~tf2/server/tf2.sh
Add the following.
#!/bin/sh
USER=$2
if [ -z $2 ]; then
USER="tf2"
fi
case "$1" in
start)
sudo -u $ tmux new-session -d -s tf2-console -d '/var/lib/tf2/server/srcds_run -console -game tf +map cp_dustbowl +maxplayers 24'
;;
stop)
sudo -u $ tmux send-keys -t tf2-console 'say Server shutting down in 10 seconds!' C-m
sleep 10
sudo -u $ tmux send-keys -t tf2-console 'quit' C-m
sleep 5
;;
*)
echo "Usage: $0 user"
esac
exit 0
Now you need to make the systemd unit. To create the unit, use your favorite editor. Here vim is used, but you can use any text editor like nano.
sudo vim /usr/lib/systemd/system/tf2.service
Add the following.
[Unit]
Description=Team Fortress 2 Server (SRCDS)
After=local-fs.target network.target
[Service]
ExecStart=/var/lib/tf2/server/tf2.sh start
ExecStop=/var/lib/tf2/server/tf2.sh stop
Type=forking
[Install]
WantedBy=multi-user.target
Now make sure the tf2.sh
file is executable.
sudo chmod +x ~tf2/server/tf2.sh
After all that, you can use systemctl
to start and stop the server. Also you can use it to make it start on boot.
To start:
sudo systemctl start tf2.service
To stop:
sudo systemctl stop tf2.service
To restart:
sudo systemctl restart tf2.service
To enable at boot:
sudo systemctl enable tf2.service
To disable at boot:
sudo systemctl disable tf2.service
Even though systemd is handling starting and stopping the server, you can still access the console with the following command:
sudo -u tf2 tmux attach -t tf2-console
SteamCMD is installed in an area where only root can change files (see note in “Install SteamCMD”). If you ever need to upgrade SteamCMD itself, just run it as root.
sudo steamcmd +quit
If you need to update the server. First stop the server and then use SteamCMD to update (using the same command to install).
sudo systemctl stop tf2.service
sudo -u tf2 steamcmd +login anonymous +force_install_dir ~tf2/server +app_update 232250 validate +quit
sudo systemctl start tf2.service
There are a lot more configuration topics that are not covered in this tutorial. If you need more information, please refer to the Team Fortress 2 Wiki and the Valve Developer Wiki.
]]>In order to host a Rust game server, you need a program called steamcmd
. With that program, we can obtain all the required game server files and start the server. But first, we need to install some packages for Steam to work properly.
If you have a 32 bit installation, run this set of commands:
yum install glibc libstdc++ screen -y
For 64 bit installations of CentOS, use this set of commands:
yum install glibc.i686 libstdc++.i686 -y
Then, once you’ve finished installing your package set, execute the following:
yum groupinstall 'Development Tools' -y
yum install libX11-devel freetype-devel zlib-devel libxcb-devel -y
yum install libX11-devel -y
yum install -y freetype freetype-devel -y
Namely, Steam requires the C/C++ runtimes installed to run properly. Alongside, this set of commands will install screen
, a program that you can use to keep other programs running after disconnecting from your SSH/console session.
We’ll create another user for security, because running the game server with the root user is dangerous. Feel free to change the user name, if you wish.
useradd rust
su rust
The useradd
command will add the user, rust. The su
command, will effectively change our current user to “rust”.
Now that we’re using the unprivileged user, we’ll create the folder where Rust will run.
mkdir ~/game_server && cd ~/game_server
Now, let’s get the Rust game server files.
wget http://playrust.com/wp-content/uploads/2015/04/Rust_Server.zip && unzip Rust_Server.zip
Because Rust requires Windows to run, we’ll be installing a program named WINE. WINE (Wine Is Not a Emulator) is a program that allows us to use Windows software on Linux. The great part is that it’s fairly simple to install.
cd /usr/src && wget http://skylineservers.dl.sourceforge.net/project/wine/Source/wine-1.7.50.tar.bz2 && tar xjf wine-1.7.50.tar.bz2
If you’re running a 64-bit installation of CentOS, use these:
cd wine-1.7.50 && ./configure --enable-win64
If you’re using the 32 bit version of CentOS, use this:
cd wine-1.7.50 && ./configure
To finish installing Wine, run:
make && make install
This will take a fair amount of time, so hang tight while Wine is being built.
Once Wine has finished compiling, execute:
cd /home/rust/game_server/steam
/usr/src/wine-1.7.50/wine64 steamcmd.exe +runscript ../update_script.txt
cd .. && cd rustds
Good job, you have successfully setup a Rust server.
To start your Rust server, execute:
su rust
cd rustds
/usr/src/wine-1.7.50/wine64 RustDedicated.exe -batchmode +server.hostname "rust-server.localdomain" +server.port 28015 +server.identity "my_server" +server.seed 1234567 -logFile "output.txt" -autoupdate
This command will start a server with the hostname rust-server.localdomain
, and the seed 1234567
. If desired, you can change the server seed, the hostname, and any of the configurable options.
To conclude, you installed a Rust server – all that’s left is to recruit some players!
]]>Any VPS from AKLWEB Host is great for an MTA server, whether it’s just a private server for friends or development, to a server that will host lots of people 24/7.
For a development server or a server for your friends, I would recommend the lowest-end VPS (768 MB ram). The more people you are hosting, the bigger the server you would get (obviously).
Lets get started!
These packages must be installed before the MTA server.
For 32-bit Debian:
apt-get update;
apt-get upgrade;
apt-get -y install zip unzip libreadline5 screen
For 64-bit Debian:
apt-get update;
apt-get upgrade;
dpkg --add-architecture i386; #add the i386 architecture so the ia32-libs package can be installed
apt-get update; #update the list of packages so the ia32-libs package is included in the list
apt-get -y install zip unzip ia32-libs lib32ncursesw5 lib32readline5 screen
Summary:
Do the steps listed below, one at a time:
cd ~;
mkdir mtasa;
cd mtasa;
wget -O mtasa-linux-server.tar.gz http://linux.mtasa.com/dl/154/multitheftauto_linux_x64-1.5.4.tar.gz;
wget -O baseconfig.tar.gz http://linux.mtasa.com/dl/154/baseconfig-1.5.4.tar.gz;
wget -O mtasa-resources.zip https://mirror.mtasa.com/mtasa/resources/mtasa-resources-latest.zip;
tar -zxf mtasa-linux-server.tar.gz;
mv multitheftauto_linux_x64-1.5.4 mtasa-server;
unzip -q mtasa-resources.zip -d mtasa-server/mods/deathmatch/resources/;
tar -zxf baseconfig.tar.gz; #uncompress default server configuration files
mv baseconfig/* mtasa-server/mods/deathmatch;
rmdir baseconfig;
rm mtasa-linux-server.tar.gz baseconfig.tar.gz mtasa-resources.zip;
Summary:
mtasa
.Run the following commands:
cd ~;
cd mtasa/mtasa-server/mods/deathmatch;
nano mtaserver.conf;
Summary:
Now, we can configure our server. All that you really need to configure in this step is the server name, the amount of slots the server can have (default is 32), and what resources it will run upon start-up. To configure your server, make any changes to the mtaserver.conf
file in nano
that you deem necessary. Once you have finished, hold CTRL and press O, then type y to save.
Run the following commands:
cd ~;
cd mtasa/mtasa-server/;
./mta-server;
Summary:
mtasa-server
folder../mta-server
to start your server.If everything is working, the MTA console should be displayed. The server will print a message stating that it is ready to accept connections.
There you go – you now have a fully working Multi Theft Auto 1.4.0 server that is ready for players!
At this point, the server is running. Once you exit the shell though, the server will stop. To keep it running when you have exited the shell, run the following commands:
cd ~;
cd mtasa/mtasa-server/;
screen -dmS mtasa ./mta-server;
Summary:
mtasa-server
folder.mtasa
(This can be whatever you want).To view your server, run screen with the process ID of the server:
screen -r PROCESS_ID
You can find the process ID of your server by running this command:
screen -ls
Your server will appear with the ID being the first number next to what you called the screen (Example: 1231.mtasa).
To exit the screen, hold down CTRL, then press A and D at the same time to exit. If you are using a shell program, such as PuTTY, then you can just close PuTTY.
To stop the server, go into the screen and type quit
in the server console.
If the server has crashed, then get the screen ID and run: kill <id>
or kill -9 <id>
.
Enjoy your new MTA server!
]]>First, install the required libraries.
yum -y install m4 automake autoconf make gcc libtool
Once these libraries have finished installing, you must install the server script. We will be using PocketMine.
wget http://downloads.sourceforge.net/project/pocketmine/linux/installer.sh
Chmod the server script to make it executable.
chmod +x ./installer.sh
Begin the install process. This may take up to 5 minutes to install.
./installer.sh
Next, start the server.
./start.sh
Voila. We just need to make sure that port 19132 is open so that people can join. To open it in CentOS 6, run the following commands.
iptables -A INPUT -p tcp -m tcp --dport 19132 -j ACCEPT
service iptables save
service iptables restart
If you are running CentOS 7, then you must use firewalld to open it. To do so, perform the following commands:
firewall-cmd --zone=dmz --add-port=19132/tcp --permanent
firewall-cmd --reload
Your server is ready to go! Happy building!
]]>This tutorial assumes that you logged in with a standard user account and have sudo privileges. We will be using a normal user account because building packages with AUR should not be done from the root account.
If you are using a 64-bit version of Arch Linux, it is very important that you have the multilib
repository enabled. If it is not enabled, SteamCMD cannot download or run the game server files. To enable multilib, simply uncomment the following lines in /etc/pacman.conf
.
[multilib]
Include = /etc/pacman.d/mirrorlist
This does not apply to 32-bit Arch Linux systems.
There is an AUR package for SteamCMD. It is possibly the easiest way to install SteamCMD on Arch. There are a few things to note about it though:
/usr/share/steamcmd
.If you are on a 64-bit server, you must install the package lib32-gcc-libs
.
sudo pacman -Sy lib32-gcc-libs
Now we must build the package. Using curl, download the tarball for the package.
curl -O https://aur.archlinux.org/packages/st/steamcmd/steamcmd.tar.gz
Once the download finishes, extract and change to the directory created.
tar -xvzf steamcmd.tar.gz
cd steamcmd
Now, using makepkg, build the package.
makepkg -ci
If you didn’t pass the -i
flag to the makepkg command, then use the following command to install it.
sudo pacman -U *.pkg.tar.xz
You now have SteamCMD installed and ready to download Counter-Strike: Global Offensive server.
This guide uses a separate user to run the server, so we will create a new csgo user and group with it’s own home folder in /var/lib
.
sudo groupadd csgo
sudo mkdir /var/lib/csgo
sudo useradd -d /var/lib/csgo -g csgo -s /bin/bash csgo
sudo chown csgo.csgo -R /var/lib/csgo
Now to install the server.
sudo -u csgo steamcmd +login anonymous +force_install_dir ~csgo/server +app_update 740 validate +quit
Once that finishes downloading, you have the server installed.
Although you can run the server, some configuration should be done so that the server isn’t too generic. The main file that we put settings in is the server.cfg
file. Below is a very basic server.cfg
file.
To open/create the file, use your favorite editor. I use vim in this example.
sudo -u csgo vim ~csgo/server/csgo/cfg/server.cfg
Add the following. More settings can be found on the Valve Developer Wiki. Be sure to change some of the settings to suit your needs.
hostname "Server Name"
rcon_password "password"
sv_password ""
sv_contact "email@example.com"
sv_tags ""
sv_region "255"
sv_lan "0"
exec banned_user.cfg
exec banned_ip.cfg
writeid
writeip
To run your server unattended, you will need a multiplexer like GNU Screen or tmux. In this article, I am going to use tmux to run the server, but if you prefer and know how to use screen, feel free to use it.
Install tmux by using pacman.
sudo pacman -Sy tmux
You can start the server with the following command. You can change the map if desired. Please read the “Final Notes” for more information on the game_type
and game_mode
values. This example is for a classic casual server.
sudo -u csgo tmux new-session -d -s csgo-console -d 'cd /var/lib/csgo/server/; ./srcds_run -console -game csgo -usercon +game_type 0 +game_mode 0 +mapgroup mg_active +map de_dust2'
If you ever need to attach to the console, run the following.
sudo -u csgo tmux attach -t csgo-console
You can leave the server console by typing CTRL + B then releasing those keys and then pressing D.
Running the server with systemd is convenient for many reasons. The main one is that you can have it start when the VPS starts. This requires a script and a systemd unit to be written. Even though this is a good idea, it is optional.
The first thing to write is the start script. To create the script, use your favorite editor. Here vim is used, but you can use any text editor like nano.
sudo -u csgo vim ~csgo/server/csgo.sh
Add the following and be sure to look at the line with the start command as it has the game mode and type.
#!/bin/sh
USER=$2
if [ -z $2 ]; then
USER="csgo"
fi
case "$1" in
start)
sudo -u $ tmux new-session -d -s csgo-console -d 'cd /var/lib/csgo/server/; /var/lib/csgo/server/srcds_run -console -game csgo -usercon +game_type 0 +game_mode 0 +mapgroup mg_active +map de_dust2'
;;
stop)
sudo -u $ tmux send-keys -t csgo-console 'say Server shutting down in 10 seconds!' C-m
sleep 10
sudo -u $ tmux send-keys -t csgo-console 'quit' C-m
sleep 5
;;
*)
echo "Usage: $0 user"
esac
exit 0
Now you need to make the systemd unit.
sudo vim /usr/lib/systemd/system/csgo.service
Add the following.
[Unit]
Description=Counter-Strike: Global Offensive Server (SRCDS)
After=local-fs.target network.target
[Service]
ExecStart=/var/lib/csgo/server/csgo.sh start
ExecStop=/var/lib/csgo/server/csgo.sh stop
Type=forking
[Install]
WantedBy=multi-user.target
Now make sure the csgo.sh
file is executable.
sudo chmod +x ~csgo/server/csgo.sh
After all that, you can use systemctl
to start and stop the server. Also you can use it to make it start on boot.
To start:
sudo systemctl start csgo.service
To stop:
sudo systemctl stop csgo.service
To restart:
sudo systemctl restart csgo.service
To enable at boot:
sudo systemctl enable csgo.service
To disable at boot:
sudo systemctl disable csgo.service
Even though systemd handles starting and stopping the server, you can access the console with the following command.
sudo -u csgo tmux attach -t csgo-console
SteamCMD is installed in an area where only root can change files (see note in the “Install SteamCMD” section). If you ever need to upgrade SteamCMD itself, just run it as root.
sudo steamcmd +quit
If you need to update the server. First stop the server and then use SteamCMD to update (using the same command to install).
sudo systemctl stop csgo.service
sudo -u csgo steamcmd +login anonymous +force_install_dir ~csgo/server +app_update 740 validate +quit
sudo systemctl start csgo.service
The game mode and game type in the starting command are important depending on what kind of server you want. Here’s a quick table of the possible values.
Game Mode | game_type | game_mode
Classic Casual | 0 | 0
Classic Competitive | 0 | 1
Arms Race | 1 | 0
Demolition | 1 | 1
Deathmatch | 1 | 2
There are a lot more configuration topics not covered in this tutorial. If you need more information, please refer to the Valve Developer Wiki.
]]>This guide will cover the installation and operation of a Call of Duty 4 (COD4) server using screen. In this tutorial, we will install COD4 on Debian 7.
Login as root on the server that you will be using for this installation.
Run the command below to update your server’s list of available packages from the repositories and then upgrade any existing packages.
apt-get update && apt-get upgrade
Screen is often times included with the OS image by default, but you may be required to install it yourself.
apt-get install screen
Because the Call of Duty 4 server only runs on i386 machines, you have to enable the “multilib” feature in Debian.
dpkg --add-architecture i386
apt-get update
For security purposes, we do not want to run the server using the root account. You should use a standard user account.
Create a directory for the game server.
cd ~
mkdir cod4
Download the Call of Duty 4 dedicated server.
cd cod4
wget http://treefort.icculus.org/cod/cod4-linux-server-06282008.tar.bz2
The download size is roughly 280 MB. When the download finishes, unpack the package.
tar -xvjf cod4-linux-server-06282008.tar.bz2
Install the COD4 game client onto your computer. Copy the main
and zone
folder of the game client onto the COD4 directory of your server using your favorite SCP client.
Once your upload completes, download the IceOps made executable. It contains various bugfixes and improvements.
wget https://iceops.in/cod4x17a_dedrun
Make the server “executable”.
chmod +x cod4x17a_dedrun
Create a config file for the dedicated server.
nano general.cfg
If you want to run a simple “Team Deathmatch” or “Search & Destroy” server, then use this sample config.
//************************************************** ****************************
// Call of Duty 4
//************************************************** ****************************
//************************************************** ****************************
// Public Information
//************************************************** ****************************
sets sv_hostname "CoD4 Server" // Change this field, what is the server name
sets _Admin "Admin" // Change this
sets _Email "admin@admin.com" // Change this
sets _Website "www.website.com" // Change this
sets _Location "Location" // Change this
sets _Irc ""
sets _Mod ""
sets _ModVer ""
sets _ModUpdate ""
sets _Maps "COD4 Stock"
set scr_motd "Message of the Day when the gamer joined the server" // Change it
//************************************************** ****************************
// Common Server Settings
//************************************************** ****************************
// Log Settings
set g_logsync "2" // 0=no log, 1=buffered, 2=continuous, 3=append
set logfile "1" // 0 = NO log, 1 = log file enabled
set g_log "games_mp.log" // Name of log file, default is games_mp.log
set sv_log_damage "1"
// Network options
set net_ip "192.168.1.1" // Set your servers IP address
set net_port "28960" // Set your port number
set com_hunkMegs "512"
set net_noipx "1" // Allow ONLY tcp/ip protocol, player/server communications
// Server Network Mode
set dedicated "2" // 0 = Listen, 1 = LAN, 2 = Internet
// Password Settings
set rcon_password "yourpass" // RCON must be set.
set sv_privatePassword "" // Private slots, non-public slots
// The following can be used to lock out the server so that only those
// players that have been provide the password can connect. Good for
// matches, practices, etc.
set g_password ""
// Player slots setup
set sv_maxclients "32" // MAX server player slots, this is TOTAL player slots
set sv_privateclients "" // Number of private player slots, maxclients - privateclients = public slots
// Ping
set sv_minPing "0" // MIN player ping on CONNECT, any lower and player isnt allowed to connect
set sv_maxping "250" // MAX player ping on CONNECT, any higher and player isnt allowed to connect
// Client Download Settings. (0=off/1=on) Used for MODs and custom maps
// You have to got a working httpd server if fast downloading enabled.
set sv_allowdownload "0"
seta sv_wwwDownload "0"
seta sv_wwwBaseURL ""
seta sv_wwwDlDisconnected "1"
// Rate
set sv_maxRate "25000"
// Drop inactive players
set sv_timeout "300"
set sv_zombietime "1"
set g_inactivity "0"
set g_inactivityspectator "0"
// AntiFlooding Settings
set sv_floodProtect "1"
set sv_reconnectlimit "3"
// Anti Cheat Settings
// In IceOps Dedicated server have their own cheat protection, so Punkbuster not needed
set sv_punkbuster "0"
set sv_disableClientConsole "0"
set cl_autocmd "0"
set sv_cheats "0"
set sv_pure "1"
set g_banIPs ""
set g_no_script_spam "1"
// Temporary Ban duration, in seconds
set sv_kickBanTime "3600"
// In-game voice communication system
set sv_voice "0"
set sv_voiceQuality "4"
set voice_deadChat "0"
set voice_global "0"
set voice_localEcho "0"
set winvoice_mic_mute "1"
//************************************************** ****************************
// Misc
//************************************************** ****************************
set sv_allowAnonymous "0"
set g_antilag "0"
set g_compassShowEnemies "0"
set scr_hardcore "1"
set g_allowvote "0"
set scr_allow_vote "0"
set scr_teambalance "1"
set ui_hud_hardcore "1"
set scr_game_allowkillcam "0"
set scr_game_onlyheadshots "0"
set scr_game_deathpointloss "0"
set scr_game_suicidepointloss "0"
set scr_team_teamkillpointloss "1"
set scr_game_spectatetype "1" // [0-2] 0=none, 1= team only, 2=spectate all
set scr_team_fftype "1" // 0=off 1=on 2=reflect damage 3=shared
//================================================== ===============================
// Gametype Settings
//================================================== ===============================
// First gametype to load
// "dm" - free for all deathmatch
// "dom" - domination
// "koth" - headquarters
// "sab" - sabotage
// "sd" - search & destroy
// "war" - team deathmatch
// Deathmatch
set scr_dm_scorelimit 150
set scr_dm_timelimit 10
set scr_dm_roundlimit 1
set scr_dm_numlives 0
set scr_dm_playerrespawndelay -1
set scr_dm_waverespawndelay 0
// Domination
set scr_dom_scorelimit 200
set scr_dom_timelimit 0
set scr_dom_roundlimit 1
set scr_dom_numlives 0
set scr_dom_playerrespawndelay -1
set scr_dom_waverespawndelay 0
// Teamdeath Match
set scr_war_scorelimit 750
set scr_war_timelimit 10
set scr_war_roundlimit 1
set scr_war_numlives 0
set scr_war_playerrespawndelay -1
set scr_war_waverespawndelay 0
// Sabotoge
set scr_sab_scorelimit 3
set scr_sab_timelimit 10
set scr_sab_roundlimit 3
set scr_sab_roundswitch 1
set scr_sab_numlives 0
set scr_sab_bombtimer 30
set scr_sab_planttime 3
set scr_sab_defusetime 3
set scr_sab_hotpotato 0
set scr_sab_playerrespawndelay -1
set scr_sab_waverespawndelay -1
// King of the Hill
set scr_koth_scorelimit 250
set scr_koth_timelimit 15
set scr_koth_roundlimit 1
set scr_koth_roundswitch 1
set scr_koth_numlives 0
set scr_koth_playerrespawndelay -1
set scr_koth_waverespawndelay 0
set koth_autodestroytime 60
set koth_spawntime 0
set koth_kothmode 0
set koth_capturetime 20
set koth_destroytime 10
set koth_delayPlayer 0
set koth_spawnDelay 60
// Search and Destroy
set scr_sd_scorelimit 6
set scr_sd_timelimit 3
set scr_sd_roundlimit 0
set scr_sd_roundswitch 3 // rounds between switching teams
set scr_sd_numlives 1 // elimination
set scr_sd_bombtimer 60
set scr_sd_planttime 7
set scr_sd_defusetime 7
set scr_sd_multibomb 0
set scr_sd_playerrespawndelay -1
set scr_sd_waverespawndelay 0
// Team-Balance and Voting
set scr_teambalance "1"
set g_allowvote "0"
set sv_mapRotation "gametype sd map mp_bloc gametype sd map mp_backlot gametype sd map mp_crash gametype sd map mp_convoy gametype sd map mp_vacant gametype sd map mp_bog gametype sd map mp_pipeline gametype sd map mp_farm gametype sd map mp_crossfire gametype sd map mp_overgrown gametype sd map mp_citystreets gametype sd map mp_showdown gametype sd map mp_strike gametype sd map mp_cargoship gametype sd map mp_countdown"
Save your changes to the config file.
Next, create a start-up script that starts a dedicated server (with screen) and enables map rotation.
nano cod4.sh
Paste the following content into the script file.
#!/bin/bash
screen -dmS cod4 ./cod4x17a_dedrun +set sv_authorizemode "-1" +exex general.cfg +map_rotate
Save your changes to the script file, then make it “executable”.
chmod +x cod4.sh
If you are using the iptables firewall, add the following rules. Update the ports if you have changed them in the server configuration file.
-A INPUT -p udp --dport 28960 -j ACCEPT
-A INPUT -p udp --sport 28960 -j ACCEPT
-A INPUT -p tcp --dport 28960 -j ACCEPT
-A INPUT -p tcp --sport 28960 -j ACCEPT
-A INPUT -p udp --dport 20800 -j ACCEPT
-A INPUT -p udp --sport 20800 -j ACCEPT
-A INPUT -p tcp --dport 20800 -j ACCEPT
-A INPUT -p tcp --sport 20800 -j ACCEPT
-A INPUT -p udp --dport 20810 -j ACCEPT
-A INPUT -p udp --sport 20810 -j ACCEPT
-A INPUT -p tcp --dport 20810 -j ACCEPT
-A INPUT -p tcp --sport 20810 -j ACCEPT
Finally, start your server.
./cod4.sh
]]>