In this tutorial, I will explain how to set up a Garry’s Mod server. This tutorial was written for CentOS 7.
Let’s make sure that the system is fully updated. Create a new user for this server, and be sure to use a strong password.
yum update
yum upgrade -y
adduser gmod
passwd gmodOpen the required firewall ports with firewall-cmd.
firewall-cmd --zone=public --add-port=27015/tcp --permanent
firewall-cmd --zone=public --add-port=27015/udp --permanent
firewall-cmd --reloadInstall the required system libraries to run SteamCMD.
yum install glibc.i686 libstdc++.i686 -yNow, switch to the user that was just created.
su gmod
cd ~Download SteamCMD by using wget.
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar xf steamcmd_linux.tar.gzInstall the game server files with SteamCMD.
./steamcmd.sh +login anonymous +force_install_dir ./gmod +app_update 4020 validate +quitWhen it says Success! App '4020' fully installed., simply type quit and press enter.
The game server is now installed.
To change the name of your server, edit the server.cfg file.
nano ~/gmod/garrysmod/cfg/server.cfgPaste the following into server.cfg and change ServerName and RconPassword to anything you would like.
hostname "ServerName"
rcon_password RconPasswordWe will create a script so that you can update your server with a single command. First, create the file update_gmod.txt.
nano /home/gmod/update_gmod.txtPaste in the following:
login anonymous
force_install_dir ./gmod
app_update 4020
quitTo update your server, you just need to run the following command:
cd ~
./steamcmd.sh +runscript update_gmod.txtNavigate to the gmod folder and run your server.
cd /home/gmod/gmod/
screen -dmS gmod ./srcds_run -game garrysmod -console -port 27015 +maxplayers 18 -tickrate 66 +map gm_flatgrassAt this point, your server is now running in the background. You may shut it down at any time with the following command.
screen -S gmod -X quitEnjoy your new Garry’s Mod server!