
Below is a detailed guide on how to set up a Half-Life server.
The operating system will be Ubuntu/Debian.
All the work of setting up the server is done in a terminal. If it's a remote machine, an SSH connection is enough.
I don't recommend downloading a ready-made Half-Life server, because ready-made servers may contain vulnerabilities that malicious players can use to gain control of the server and wreck it, which is not exactly great. Building your own server isn't much harder than downloading a ready-made one, and on top of that it will give you fewer problems down the road.
HL server requirements:
CPU: 1000 MHz or more
RAM: 128 MB or more
Hard disk space: 1.5 GB or more
If the system is 64-bit, you need the library that supports 32-bit applications
You can install it by entering the command
aptitude install lib32gcc1
Installing the server:
You'll need superuser rights to install the server.
Connect via SSH.
If you didn't connect as root, run the following command
sudo -s
Create the directory on the server where our HLDS will live
mkdir /opt/hldir
Server security comes first. Under no circumstances should you run our future server as root. You need to create a new user and give it minimal rights, since the HLDS server doesn't need much: mostly writing logs and reading files.
Add a new group that the user will belong to.
addgroup --system hldm
where hldm is the name of the new group. The name doesn't matter; you can pick any name you like.
Add the user hldm
adduser --system --home /opt/hldir --shell /bin/sh --ingroup hldm --disabled-password --disabled-login hldm
where
--home /opt/hldir - the home directory with the game
--ingroup hldm - the group the user belongs to
--disabled-login hldm - the name of our user
Go to our directory to download the necessary files into it
cd /opt/hldir
Download the tool needed to build the server automatically from the Steam website.
wget http://storefront.steampowered.com/download/hldsupdatetool.bin
Now give our file the rights it needs to run
chmod +x hldsupdatetool.bin
+x means the file is allowed to execute
-x means the file won't execute
Run our tool:
su hldm -c './hldsupdatetool.bin'
If the previous command didn't work, you can also use this one; in that case the program will run as the superuser./hldsupdatetool.bin
Once it starts, we'll see the license agreement. Type YES to agree and press ENTER.
A few more files will appear in the game folder. We need the steam file to build the server. Give it the necessary rights.
chmod +x ./steam
And run it
su hldm -c './steam'
You'll see a message roughly like this
Checking bootstrapper version ...
Getting version 45 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .
Steam Linux Client updated, please retry the command
Getting version 45 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .
Steam Linux Client updated, please retry the command
Repeat the command
su hldm -c './steam'
Now you'll see roughly the following:
Checking bootstrapper version ...
Getting version 45 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .Steam Linux Client updated, please retry the command
CAsyncIOManager: 0 threads terminating. 0 reads, 0 writes, 0 deferrals.
CAsyncIOManager: 21 single object sleeps, 0 multi object sleeps
CAsyncIOManager: 0 single object alertable sleeps, 0 multi object alertable sleeps
Getting version 45 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .Steam Linux Client updated, please retry the command
CAsyncIOManager: 0 threads terminating. 0 reads, 0 writes, 0 deferrals.
CAsyncIOManager: 21 single object sleeps, 0 multi object sleeps
CAsyncIOManager: 0 single object alertable sleeps, 0 multi object alertable sleeps
That's it, the hardest part of setting up a Half-Life server is done. Now all that's left is to download the server itself and run it.
Run the following command
su hldm -c './steam -command update -game valve -dir .'
Or
./steam -command update -game valve -dir .
Where dir .
the dot is the directory where steam itself is; if you want to install into a different folder, you need to specify it, for example dir team, dir gungame and so on.
For those installing Counter-Strike or another game rather than Half-Life:
In the -game parameter, specify cstrike instead of valve
Now all the files the server needs to run will be downloaded. How fast this finishes depends on your internet connection.
After the installation, create the folders the server needs to work properly
mkdir -p valve/SAVE
mkdir -p platform
mkdir -p platform/SAVE
mkdir -p platform
mkdir -p platform/SAVE
Give the rights to run the server
chmod +x ./hlds_run
Start our server
su hldm -c './hlds_run -game valve +ip (your server IP) +port 27015 +maxplayers 32 +map crossfire'
Be sure to run it as the hldm user; if some rights are missing, for example writing to the logs folder, grant them.
Running the server as root is strongly discouraged.
If you did everything right, you should see something roughly like this:
Auto detecting CPU
Using Pentium II Optimised binary.
Auto-restarting the server on crash
Console initialized.
Protocol version 48
Exe version 1.1.2.6/Stdio (cstrike)
Exe build: 16:56:12 Mar 8 2010 (4883)
STEAM Auth Server
Server IP address ....
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
couldn't exec listip.cfg
couldn't exec banned.cfg
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
Connection to Steam servers successful.
VAC secure mode is activated.
Using Pentium II Optimised binary.
Auto-restarting the server on crash
Console initialized.
Protocol version 48
Exe version 1.1.2.6/Stdio (cstrike)
Exe build: 16:56:12 Mar 8 2010 (4883)
STEAM Auth Server
Server IP address ....
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
couldn't exec listip.cfg
couldn't exec banned.cfg
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
Connection to Steam servers successful.
VAC secure mode is activated.
If errors show up, try checking the following:
The server launch parameters, for example +port 27015; try a different port, maybe 27015 is already in use.
If the program couldn't get the CPU info, run this before each server start
Error:
[S_API FAIL] SteamAPI_Init() failed; unable to update local steamclient. Continuing with current version anyway.
Unable to determine CPU Frequency. Try defining CPU_MHZ.
Segmentation fault
Fix:
export CPU_MHZ=2000
Customizing the server
Install metamod
Install amxxmod
If you need a non-Steam server, you have to install dproto
Don't forget to configure the server.cfg configuration file
Read more about fine-tuning a Half-Life server here
Папки /SAVE движок создаёт сам, при наличии нужных прав.
Давать права на запуск hlds_run не обязательно, если сервер устанавливается при помощи hldsupdatetool.bin :)