Specfically for Centos / RHEL but broadly applicable. You should have general familiarity with Linux before you attempt this.
- As your normal user create a screen – this is a virtual terminal your server will be running in, I strongly suggest you get familiar with screen
screen
- In one of the screen windows, su to root
su - root
- Create a user to run the server as & set a password, eg l4d2
adduser l4d2 passwd l4d2
- Su to that user
su - l4d2
-
Download hldsupdatetool.bin & run – this will create a steam executable
wget http://www.steampowered.com/download/hldsupdatetool.bin chmod +x hldsupdatetool.bin ./hldsupdatetool.bin
- Download the L4D2 server – this will take time
./steam -command update -game left4dead2
- Create a basic config file
vi left4dead2/cfg/server.cfg
Example Contents:
hostname "My Cool L4D2 Server" // Server Name rcon_password "changethis" //Set remote control password sv_lan 0 // Disable LAN mp_disable_autokick 1 // Disable Autokick sv_cheats 0 // Disallow Cheats sv_clearhinthistory 0 //Clear Server Side Hint History sv_consistency 1 //Enforce file consistency sv_pausable 0 //Server not pausable sv_allow_lobby_connect_only 0 // Disable Lobby Connections sv_voiceenable 1 sv_alltalk 1 sv_region 3 // set this to your region if required (3 = Europe) //sv_steamgroup 999 // set this if required z_difficulty hard sv_search_key "hohum" sv_gametypes "coop"
- Start the server (with your own IP address here)
cd ~/left4dead2 ./srcds_run -game left4dead2 +maxplayers 4 +ip 123.45.67.89
- To kill the server just hit ctrl-c. You can now disconnect or reconnect to the screen the server is running in.
Every so often you may need to update to the latest version of the server, just kill it & run line 6 again.
If your linux box is firewalled with iptables, you may need to open ports 27015 & 27005 tcp & udp, eg have lines like
-A RH-Firewall-1-INPUT -m udp -p udp --dport 27015 -j ACCEPT -A RH-Firewall-1-INPUT -m udp -p udp --dport 27005 -j ACCEPT -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 27015 -j ACCEPT -A RH-Firewall-1-INPUT -m tcp -p tcp --dport 27005 -j ACCEPT
in
/etc/sysconfig/iptables
& do a
service iptables restart
Popularity: 100% [?]
If you have an problem, try “./steam -command update -game left4dead2 -dir .”
For linux you should add “-autoupdate” to your start command so the server won’t go down every time steam updates. (this is a linux only command)
You don’t want to use sv_search_key unless it’s a private server. This disables all public lobbies.