This tutorial will cover the process of installing a Half-Life 2 game server on CentOS 6 System.
To set up our Half-Life 2 server, we’ll need to install SteamCMD (Steam’s game server client) and its requirements.
yum install glibc libstdc++yum install glibc.i686 libstdc++.i686That’s all SteamCMD requires (the libraries required to compile C++ code and execute it).
Lastly, for this step, we’ll install a Linux utility called screen screen, which allows us to keep the gameserver running process even after we disconnect from our SSH prompt.
yum install screenMoving on, for security purposes, we will be creating another user to run the game server. Execute the following:
useradd -m gameserverBefore we drop our root privileges, we need to open up some base ports to allow players to connect.
iptables -I INPUT -p tcp --dport 27015 -j ACCEPT
iptables -I INPUT -p tcp --dport 27020 -j ACCEPT
service iptables save
service iptables restartNow, log in as your new user account:gameserver.
su gameserverThe next step will be downloading the libraries needed for SteamCMD:
mkdir SteamCMD
cd SteamCMD
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gzAnd extract the archive:
tar xvf steamcmd_linux.tar.gzNow that SteamCMD is installed, we can move forward to installing the game server.
Execute ./steamcmd.sh:
./steamcmd.shExecuting the above command will allow Steam to self-update. Once updated, you will see the Steam > prompt. You will then log in to the Steam Server:
login anonymousNext, install the halflife2 server:
force_install_dir ./halflife2
app_update 238430 validate
exitThe above command will install Half-Life 2’s server file to the directory specified above within your SteamCMD Directory.
The next step would be to configure the server:
cd halflife2Open up your text editor to cfg/server.cfg:
nano cfg/server.cfgAdd the following:
// Half Life 2 configuration
hostname "Half Life 2 Server"Change the contents between the double quotes to your desired hostname.
The next and final step would be to start the server:
Follow the steps below to start the server:
cd /home/gameserver/SteamCMD/halflife2/
screen
./srcds_run -game hl2mp +port 27020 +map dm_lockdown +maxplayers 8 -autoupdateThis concludes our tutorial. Thank you for reading.