Install Counter Strike 1.6 Dedicated Server on Debian / Linux

Counter-Strike 1.6

I’ve decided to install a Counter Strike 1.6 Dedicated Server for the old times sake, and I’ve realized that a lot of the stuff available in the past is no more… Part of this because of the migration to CS:GO and part because the developers lost their interest or got married :)

So in this article I will try to present, step by step and up to date, how to:

  1. Install Counter Strike 1.6 Dedicated Server;
  2. Configure and run the Server (metamod, amxmodx, [dproto], add admins);
  3. Install Server Stats (HLstatsX:CE);

Install Counter Strike 1.6 Dedicated Server

  • For this example I’ve used a Debian 8.0 Jessie amd64 installation. First thing what we need to do it’s to add “contrib” and “non-free” to apt sources list. In the file “/etc/apt/sources.list“, on every line you find:
...../debian/ jessie main

add “contrib non-free” and make it look like this:

...../debian/ jessie main contrib non-free

save the file and run:

apt-get update
apt-get upgrade
  • Get rid of “dash“:
dpkg-reconfigure dash
  • Now we are up to date, enable multiarch (only if you have an amd64 distribution like mine, if you are on i386 skip this step):
dpkg --add-architecture i386
apt-config update
  • Install dependencies:
apt-get install lib32gcc1 lib32tinfo5 tmux gdb mailutils postfix ca-certificates perl perlconsole unzip unrar

For Debian x32 don’t install “lib32gcc1” and “lib32tinfo5”.

On Postfix installation choose “Local only”. After installation edit and comment last two line of the “/etc/postfix/main.cf” file:

..........
inet_interfaces = loopback-only
#default_transport = error
#relay_transport = error

Restart postfix and check if it’s ok:

/etc/init.d/postfix restart
echo "It's working" | mail -s "Test from CS Server" your@address.tld

Check your e-mail (also check Spam folder)

Install “MariaDB” (or “MySQL”) and “Apache2” (these two are needed for game statistics and admins):

apt-get install mariadb-server apache2 php5 php5-geoip php5-mysql php5-gd

 

  • It’s recommended that you add a new user for the server environment and run the server as that user:
adduser --disabled-password --disabled-login steam
su - steam
  • In the “steam” user directory create a folder, “server” for example, and download the script from “Game Server Managers_” (we are using this because it provides easy Install/Update/Monitor sollution for SteamCMD):
mkdir server
cd server
wget http://gameservermanagers.com/dl/csserver
chmod +x csserver
./csserver install

*It’s possible to fail first time installation, just run “./cssserver install” again and answer “Y

  • After the successful install, run the server for the firs time and connect the console to it:
./csserver start
./csserver console

*Pay attention to the “Warning” and use “CTRL+b d” to exit from console.

*Ignore this, if you see it:

[S_API FAIL] SteamAPI_Init() failed; SteamAPI_IsSteamRunning() failed.
  • Now our server should be up and running if everything went OK, and we can go to next step:

Configure and run the Server

  • First we need to add “Metamod” and “AMX Mod X” to the server, to provide administration and further script installing. I would recomend choose to use “AMX Mod X” with “MySQL“:
  • Edit file “liblist.gam” in the “cstrike” directory:
...
gamedll_linux "dlls/cs.so"
...
...
gamedll_linux "addons/metamod/dlls/metamod.so"
...
  • Edit/Create file “cstrike/addons/metamod/plugins.ini” and add:
linux addons/amxmodx/dlls/amxmodx_mm_i386.so
  • Download this “cs-server.cfg” and replace the one in “~/server/serverfiles/cstrike/” and then open the file and edit onfiguration:
hostname "Your CS 1.6 Server"
...
sv_contact "your@address.tld"
...
sv_region 3
...
rcon_password "YouRsUperSeCret"
...
  • Restart CS Server and check that modules loaded successfully:
cd ~/server/
./csserver restart
./csserver console
  • In console run “meta list” command, you should see something like this:
meta list
Currently loaded plugins:
      description      stat pend  file              vers      src  load  unlod
 [ 1] AMX Mod X        RUN   -    amxmodx_mm_i386.  v1.8.2    ini  Start ANY  
 [ 2] Fun              RUN   -    fun_amxx_i386.so  v1.8.2    pl1  ANY   ANY  
 [ 3] CStrike          RUN   -    cstrike_amxx_i38  v1.8.2    pl1  ANY   ANY  
 [ 4] CSX              RUN   -    csx_amxx_i386.so  v1.8.2    pl1  ANY   ANY  
4 plugins, 4 running
  • edit “~/server/serverfiles/cstrike/addons/amxmodx/configs/plugins.ini” (if you don’t want MySQL based admin table, skip this step and just add your admin users to “~/server/serverfiles/cstrike/addons/amxmodx/configs/users.ini” following the examples in that file or from HERE):
; Admin Base - Always one has to be activated
;admin.amxx     ; admin base (required for any admin-related)
admin_sql.amxx  ; admin base - SQL version (comment admin.amxx)
  • Create Database and Table for admins:
mysql -u root -p
CREATE DATABASE amxmodx
  DEFAULT CHARACTER SET utf8
  DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON amxmod.* TO amx_user@localhost IDENTIFIED BY 'yours3cret';
FLUSH PRIVILEGES;
USE amxmodx;
CREATE TABLE `admins` (
  `id`            BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `auth`          varchar(32) CHARACTER SET utf8,
  `password`      varchar(32) CHARACTER SET utf8,
  `access`        varchar(32) CHARACTER SET utf8,
  `flags`         varchar(32) CHARACTER SET utf8
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
  • Add your first admin:
USE amxmodx;
INSERT INTO `admins` VALUES ('', 'Player','s3cret','abcdefghijklmnopqrstu','a');
USE amxmodx;
INSERT INTO `admins` VALUES ('', 'STEAM_0:0:12345678','','abcdefghijklmnopqrstu','a');
  • Edit “~/server/serverfiles/cstrike/addons/amxmodx/configs/sql.cfg“:
amx_sql_host    "127.0.0.1"
amx_sql_user    "amx_user"
amx_sql_pass    "yours3cret"
amx_sql_db      "amxmodx"
amx_sql_table   "admins"
amx_sql_type    "mysql"
  • Edit “~/server/serverfiles/cstrike/addons/amxmodx/configs/amxx.cfg“,
amx_password_field "_mine"

Edit any other values as you think fit for your server.

  • Restart server with “~/server/csserver restart” and enter game to check if you admin it’s working:
name Player
setinfo "_mine" "s3cret"
connect your.server.tld
amx_help

You should have all the commands available (kick, ban, etc)

  • Install “dproto” (permits non-Steam clients to connect to your server). I recommend this only for test purposes only ! Download it from HERE and extract the archive:
unzip dproto_0_9_391.zip
mkdir ~/server/serverfiles/cstrike/addons/dproto
cp bin/Linux/dproto_i386.so ~/server/serverfiles/cstrike/addons/dproto/
cp dproto.cfg ~/server/serverfiles/cstrike/
  • Edit “~/server/serverfiles/cstrike/addons/metamod/plugins.ini” and add “dproto_i386.so” as first plugin:
linux addons/dproto/dproto_i386.so
linux addons/amxmodx/dlls/amxmodx_mm_i386.so
  • Restart server and connect to console:
cd ~/server/
./csserver restart
./csserver console
meta list
Currently loaded plugins:
      description      stat pend  file              vers      src  load  unlod
 [ 1] dproto_EF        RUN   -    dproto_i386.so    v0.9.391  ini  Start Never
 [ 2] AMX Mod X        RUN   -    amxmodx_mm_i386.  v1.8.2    ini  Start ANY  
 [ 3] Fun              RUN   -    fun_amxx_i386.so  v1.8.2    pl2  ANY   ANY  
 [ 4] CStrike          RUN   -    cstrike_amxx_i38  v1.8.2    pl2  ANY   ANY  
 [ 5] CSX              RUN   -    csx_amxx_i386.so  v1.8.2    pl2  ANY   ANY  
 [ 6] MySQL            RUN   -    mysql_amxx_i386.  v1.8.2    pl2  ANY   ANY  
6 plugins, 6 running
  • Other files you should edit and set preferences for your server:
#Message of the Day (Message displayed when you first connect to server)
motd.txt
#Server config
cs-server.cfg
#dproto config
dproto.cfg
#AMX Mod X Config
addons/amxmodx/configs/amxx.cfg
#AMX Mod X Plugins
addons/amxmodx/configs/plugins.ini

Server Stats with HLstatsX:CE

mkdir ~/hlstats
cd ~/hlstats
wget https://bitbucket.org/Maverick_of_UC/hlstatsx-community-edition/downloads/hlxce_1_6_19.tar.gz
tar -zxvf hlxce_1_6_19.tar.gz
#delete default index.html from web directory
rm -f /var/www/html/index.html
#Copy html files to your DocumentRoot
cp -r /home/steam/hlstats/web/* /var/www/html/
cd /var/www/html/
#Fix file permissions:
chown -R www-data:www-data *
#Set 755 for dirs and 644 for files
chmod -R ugo-x,u+rwX,go+rX,go-w ./

If you have a separate Web Server you can upload “web” folder to the “stats/” folder in your web server and you will access it through “http://web.server.tld/stats”. Just give MySQL access to “hlstatsx” database to the Web Server also.

  • Create database and database user for HLstatsX:
CREATE DATABASE hlstatsx
  DEFAULT CHARACTER SET utf8
  DEFAULT COLLATE utf8_general_ci;
GRANT ALL ON hlstatsx.* TO hlstats_user@localhost IDENTIFIED BY 'yours3cret';
FLUSH PRIVILEGES;
  • As “steam” user go to “~/hlstats/sql/” folder:
mysql -u"hlstats_user" -p"yours3cret" hlstatsx < install.sql
  • Go to “~/hlstats/scripts/” folder:
#make sure that script files are executable:
chmod +x hlstats-awards.pl hlstats.pl hlstats-resolve.pl run_hlstats
  • Edit “hlstats.conf” and add database information:
# DBHost - Database server "address" or "address:port". Address can be an IP or
# a hostname. The default MySQL port is 3306 (tcp).
DBHost "localhost"
# DBUsername - User to connect to the database as.
DBUsername "hlstats_user"
# DBPassword - Password for the database user.
DBPassword "yours3cret"
# DBName - Name of the database to use.
DBName "hlstatsx"
  • Edit “config.php” in the web folder (“/var/www/html” or stats folder from your web server) and also add database information:
// DB_ADDR - If web interface is on other server here give the ip of the MySQL DB
define("DB_ADDR", "localhost");
// DB_USER - The username to connect to the database as
define("DB_USER", "hlstats_user");
// DB_PASS - The password for DB_USER
define("DB_PASS", "yours3cret");
// DB_NAME - The name of the database
define("DB_NAME", "hlstatsx");
// DB_TYPE - The database server type. Only "mysql" is supported currently
define("DB_TYPE", "mysql");
  • Add script files to crontab (“crontab -e“):
*/5 * * * * cd /home/steam/hlstats/scripts/ && ./run_hlstats start >/dev/null 2>&1
15 00 * * * cd /home/steam/hlstats/scripts/ && ./hlstats-awards.pl >/dev/null 2>&1
  • Download fixed “GeoLite_Import.sh“, add database info and run it to add GeoIP data to MySQL database:
wget "https://www.net-zone.ro/download/GeoLite_Import.sh"
chmod +x GeoLite_Import.sh

# Login information for your MySQL server
DBHOST="localhost"
DBNAME="hlstatsx"
DBUSER="hlstats_user"
DBPASS="yours3cret"

./GeoLite_Import.sh
  • Edit “/home/steam/server/serverfiles/cstrike/cs-server.cfg” and configure “logaddress“:
// logaddress_add ip port Log to ip:port (for hlstats)
// add ip address of "hlstats.pl"
logaddress_add 192.168.10.100 27500
  • Access hlstats interface and configure server (default user/pass – admin/123456);
  • Go to “Admin Users“, add another admin, login with the new admin and delete default user;
  • Go to “Games” and enable Counter Strike 1.6;
  • Go to “Game Settings > Counter-Strike (cstrike)”  and “Add Server“;
  • Go to “HLstatsX:CE Settings“, edit settings as you like, make sure under “GeoIP data & Google Map settings” you select “GeoIP lookup via database“;
  • Go to “Tools > HLstatsX: CE Daemon Control” and reload daemon configuration.