Tutorial - Dedicated Gmod server under Linux (from A to Z +ULX +anti-crash)



Script Daniel Gibbs : https://linuxgsm.com/lgsm/gmodserver/

Config 1 FTP per user : http://www.tutoriels-video.fr/installation-dun-serveur-ftp-et-configuration-dun-nom-de-domaine-dn/
Full Workshop tutorial : https://www.terageek.org/tuto/configurer-le-workshop-de-son-serveur-garrys-mod-sous-linux-ou-windows/
Tuto activate the console : https://www.terageek.org/tuto/activation-de-la-console-dans-les-jeux-valve/
Download ULX : http://ulyssesmod.net/downloads.php

Install the necessary packages

They may vary, but you can find them here : https://linuxgsm.com/lgsm/gmodserver/

Add a user

adduser gmodserver

Choose a password, and press enter until it is created

Log on to the user :

su - gmodserver

Download the script

wget https://linuxgsm.com/dl/linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh gmodserver

Start installation

./gmodserver install

Once you've finished, type "y" if the installation went well, and "y" for the GameServer Query, which will give you much better serv crash detection.

Next, choose an RCON server name and password (you can change them later in /serverfiles/garrysmod/cfg/gmod-server.cfg ).

Start/stop/restart/check update server

Basic controls

./gmodserver start
./gmodserver stop
./gmodserver restart

Useful information about the server and the machine

./gmodserver details

Manually check whether the serv is in a state of crash (you can automate this task every X minutes, we'll see about that later)

./gmodserver monitor

Update

./gmodserver update
./gmodserver update-restart

Configuring your server

nano gmodserver

(Remember, to exit "nano", ctrl + q, then "y" to confirm changes or "n" to cancel) then "enter".

Inside, you'll find some interesting variables

emailnotification="on"

Which allows you to receive an email in the event of a server crash. And you add your email address. You can then do

./gmodserver email-test

to check receipt of the e-mail

workshopauth="xxxxxxxxx"
 workshopcollectionid="xxxxxxxxx"

For the workshop, see the full tutorial here: https://www.terageek.org/tuto/configurer-le-workshop-de-son-serveur-garrys-mod-sous-linux-ou-windows/

The default map

defaultmap="gm_construct"

Maximum number of players

maxplayers="32"

Fix hunk for rp_rockford_v1b and others

After the configurations, add :

commands="+r_hunkalloclightmaps 0 +tv_enable 0"

then at the end of parms= " ", add :

${commands}

Port configuration

If you only have one server, leave as default.

For port configuration, there's the main port, used to connect ("port"), the "spectator" port (I don't even know if it's used in gmod) and the "client" port, which is essential.

If you have several servers, I recommend that you proceed as follows:

- port: from 27025 to 27049

- sourcetvport : from 27050 to 27074

- clientport : from 27000 to 27049

In theory, this means you can run up to 24 servers on the same machine...

So for the first server it looks like :

port="27025"
sourcetvport="27050"
clientport="27000"

IP, to be entered only if your server has several network cards

ip="0.0.0.0"

Using the console

To see what's going on or write commands, you can use the server console.

./gmodserver console

You confirm the warning that says "don't quit with ctrl + c or you'll close the server".

And to exit the console properly, you need to press: ctrl + b, then d! (and not ctrl + b + d at the same time)

View logs

In the event of a problem with a plugin, kikoo crashing the serv, doubts about the config, verification or anything else, it's always a good idea to check the logs!

At the root, you have a "log" folder with the console log and the script log.

Automate the server

We're going to try to : Update and reboot the server once a day, and check for crashes every 5 minutes (don't go below 3 or you risk having anti-crash check loops).

Two ways: As root, or with the user. A single server or no root access: use the user. Several servers: use root.

In all cases, the command to access automation :

crontab -e

Then add :

In root :

0 5 * * *  su - gmodserver -c /home/gmodserver/gmodserver update-restart' > /dev/null 2>&1

*/5 * * * * su - gmodserver -c '/home/gmodserver/gmodserver monitor' > /dev/null 2>&1
 

En user :

0 5 * * * /home/gmodserver/gmodserver updaterestart > /dev/null 2>&1

*/5 * * * * /home/gmodserver/gmodserver monitor > /dev/null 2>&1

In both cases, if you have several servers, make sure that the file is the right one!

And there you have it!

If you have any questions, feel free to comment!

 Enjoy the game!

Full Workshop tutorial : https://www.terageek.org/tuto/configurer-le-workshop-de-son-serveur-garrys-mod-sous-linux-ou-windows/

Coming soon: More details in writing.

Comments

66 responses to "Tutorial - Dedicated Gmod server under Linux (from A to Z +ULX +anti-crash)”

  1. [...] See also: Creating a dedicated Garry's Mod server under Linux [...]

  2. Angefatal avatar
    Angefatal

    Good evening,

    I have a small problem, my server is not listed in Europe, I think that my host "Pulseheberg" has these machines in the USA so steam recognizes that in the USA, I'm a little drunk to rent another server but would you have a site good value for money or are hosted machines in France or Europe in any case?

    1. UltimateByte avatar

      You're not the only one with this problem. Strangely, all those who have it are at Pulseheberg. Try in your config file: sv_region 3 for europe (it's not the IP that determines where your server is detected but this config, which by default is 255 for "world").
      CF : https://developer.valvesoftware.com/wiki/Sv_region

      1. UltimateByte avatar

        Apparently it's the IP that determines the location of the server, despite the sv_region setting... So the solution is to find a way to have a Geolocalised IP in France. Sorry for you ://

  3. UltimateByte avatar

    Hi, here's a hint: config file sv_location if I'm not mistaken ^^

  4. Angefatal avatar
    Angefatal

    I've already changed to 3 Europe but it's no use.

    1. UltimateByte avatar

      So just to keep you informed, it's pulseheberg's servers whose ip addresses are incorrectly detected... At least they're not detected in France by gmod's geolocation services...

  5. Quartz avatar
    Quartz

    Hi, I'd just like to know where to download the console at the beginning of your video because I'm blocking it.

  6. Skolite avatar
    Skolite

    Good morning,
    I have a small problem with my server which is as follows: when I connect to my server, it downloads the map and then disconnects me by saying that I didn't download the map :/.

    Thank you for your time.

    1. DrStrax avatar
      DrStrax

      If it says Missing Map "map name" you download the map separately ;)

  7. oligan21 avatar
    oligan21

    I've made a gmod server on a vps but I can't get it to boot when the vps starts.

    1. UltimateByte avatar

      crontab -e , then the command given by DanielGibbs, a "monitor" will suffice, if the serv is down it will restart! (you need to have gsquery installed for better detection)

  8. HydroDiX avatar
    HydroDiX

    I have a problem when I install the 1 package and it gives me two ERRORs.

    1. UltimateByte avatar

      Which package and which error messages?
      nano /etc/apt/sources.list
      Check that your package sources are already in order ;)

  9. Alan700 avatar
    Alan700

    Hello everyone, I have a small problem when I go into the console I get an error message "Server restart in 10 seconds
    ./srcds linux: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory Add "-debug" to the ./srcds_run command line to generate a debug.log to help with solving this problem "
    If anyone knows why this is happening, please respond.

    1. UltimateByte avatar

      :hi: Daniel Gibbs' fix doesn't seem to work any more, I'll have to talk to him about it.
      The command: Go to the root of your serv and do :
      cp steamcmd/linux32/libstdc++.so.6 serverfiles && steamcmd/linux32/libstdc++.so.6 serverfiles/bin

      And you restart ;)

      Keep me posted.

      1. Alan700 avatar
        Alan700

        I'm having a bit of a problem with it saying "segregation error".

        1. Alan700 avatar
          Alan700

          nn en faite c'est bon. Thank you:

  10. ChipusS avatar
    ChipusS

    I would like to know how to change mods for deathrun, dark rp, mini-games, I sue download the file (I am on linux kimsufi server for the preparation) I would like to know how to do to change.

    1. UltimateByte avatar

      nano serverfiles

      => gamemode

  11. Raoul Massardy-Vincent avatar

    Hello/Bonoir,

    After studiously watching your video, which was a great help to me... I still have a few questions.
    I was able to find out more about mesnie.org and its various servers after watching this video.
    I'd like to know what type of machine you host your servers on (one or more).
    What's more, if you're using a single machine, how much ram should you allocate to each server? (For example: a murder server with ten or so connected users and a prophunt server with ten or so connected users).
    Thank you in advance!

    1. UltimateByte avatar

      Hi, there,
      Glad I could be of help!
      You can find out more about our server here: http://www.mesnie.org/news/migration-terminee-achevez-moi-please-le-debrieffing/

      RAM allocation: where did you hear about that? A Gmod server takes the RAM it needs, i.e. about 1.2GB in points for a large DarkRP, 350-500MB for a sandbox/murder, etc. You don't have to do anything extra and you can't set this value in all cases.

      Unless you have lots of objects on the map (build, darkrp), even a crappy server will be fairly quiet in terms of resources, even with lots of players. As soon as you have, say, 16GB of RAM, a Xeon and 100mbits/s you can already run quite a few servers on the same machine. Look at the IPs of our servers and you'll see that they're all on the same machine, and remember that we're not even reaching saturation point. Before we started DarkRP, we made do with a fairly basic server at Online.net, and that didn't do too badly!

  12. Raoul Massardy-Vincent avatar

    Thank you for your comprehensive reply!
    I'll take a look at your configuration.
    Have a nice day and thanks again...

  13. sayvi avatar
    sayvi

    bonjour j'ai un problème quand je boot sa me fait [ FAIL ] Starting gmod-server: Tmux not installed
    * Tmux is required to run this server.
    * Please see the following link.
    * http://gameservermanagers.com/tmux

    1. UltimateByte avatar

      Hi, there,
      You probably didn't follow the 1.40m part of the tutorial.
      https://youtu.be/Zxy-pOZZk5c?t=96
      In short: install the right packages for your distro, including tmux.
      Good luck ;)

  14. NRPC avatar
    NRPC

    Hi there!
    Thank you so much for your tutorial!
    I have a problem with my server. I host it on a Linux computer, I've opened the ports on my box, the server appears in sandbox, but when I try to connect I get an error message: "Connection failed after 4 retries"! Can you help?

    Thanks in advance, NRPC!

    1. UltimateByte avatar

      Hello!
      The serv console seems to be saying that everything is in order?
      If you try to connect with the local IP does it work?
      Did you redirect the ports correctly?

      1. NRPC avatar
        NRPC

        First of all, thank you for your reply.

        I had misunderstood in the tutorial, I modified the 3 ports as said in the tutorial, although it is my only server. But I did open the ports that corresponded to the ports replaced in the config. Is this what you meant by redirected?
        I'll try to connect with the local IP.
        And the console doesn't indicate anything abnormal.

        Thank you in advance!

        1. UltimateByte avatar

          You're welcome! In fact, "opening a port" works when you have a firewall. This is a port redirection to a local IP ;)

      2. NRPC avatar
        NRPC

        So I can connect with the local IP address:port

      3. NRPC avatar
        NRPC

        Another problem, I can't execute !menu. But I put it in the right directory...

        1. UltimateByte avatar

          You've put ULX and ULIB in the addons folder, and restarted the serv, and you can't see ULX?
          By the way, full tutorial on ULX if you have the faith https://www.youtube.com/watch?v=GDvq40ChH_U

  15. Mickael avatar

    :hi: When I start the server I get this error in the console: Auto detecting CPU
    Using default binary: ./srcds_linux
    Server will auto-restart if there is a crash.
    ./srcds_run: line 372: 11603 Segmentation error $HL_CMD
    Add " -debug " to the ./srcds_run command line to generate a debug.log to help with solving this problem

    1. UltimateByte avatar

      :hello:
      The real support is here: http://steamcommunity.com/groups/linuxgsm/discussions/0/
      Segfaults can have dozens of reasons, so without a ./gmodserver details I have no viable leads.

      1. Mickael avatar

        I've just posted it on the group thanks :)

        1. UltimateByte avatar

          There was indeed a bug in LGSM, the glibc libraries were fixed even when they shouldn't have been.
          Problem solved with Daniel (creator and main dev of LGSM). :)

          1. Mickael avatar

            Thank you:

  16. skillz_tv avatar

    :hi: I can't install CSS on my server so I have to go through certain props like benches. Can you teach me how to do it :please: ?

    1. UltimateByte avatar

      CF Youtube comments:

      > Playteams Server2 months ago
      How can I add css textures?
      >>UltimateByte2 months ago
      By installing a CSS serv using the same method as for garry's mod, in a dedicated user, and modifying the mount.cfg of your gmod to point to this CSS ;)

  17. Antoine Kem's avatar

    Hello,
    I don't know if the support is still active, but we'll give it a try!
    So I installed a gmod server following your tutorial (thank you, I managed to do it very easily), but now I need your help ...
    I'd like to install a Loading Screen, but I don't know which file to put it in & which command . I've tried 2 - 3 things on the web but nothing works ...
    Thank you in advance!
    Have a nice day.

    1. UltimateByte avatar

      Support is still active ;)
      Once you have your site or your page up and running, all you have to do is put the url in the gmod config file. Typically: serverfiles/garrysmod/cfg/gmod-server.cfg, then sv_loadingurl " http://ton-url.com/whatever ", then reboot the gmod serv. Done.

      1. Antoine Kem's avatar

        Re,
        Thank you for your reply. Unfortunately it doesn't work. Could it be a link error? My link is uranium-roleplay.fr//teeload/load.php?steamid=%s So it's in another file, maybe the loading screen would like it to be directly accessible? I don't really know what the problem is...

        1. UltimateByte avatar

          Problem solved according to feedback received on TS. Apparently Gmod does not support https.

  18. MarOwN avatar

    Hello,
    You say that at pulseheberg the server is only visible in the USA but I am at pulseheberg, and I have no problem, my server is visible everywhere ^^.

    a+ in play!

    1. UltimateByte avatar

      So much the better if the GeoIP database has been updated. If only that were the only problem at Pulseheberg... Good luck, I'm not going back! CF: https://www.terageek.org/news/le-grand-demenagement-parcours-dun-romanichel/

  19. alex_janoski avatar
    alex_janoski

    Yo people I have a problem with my server .....
    When I am in the console (I am on putty) nano gmodserver and I enter the box ln there is nothing written someone can help me please ?!!!! :ouch2:

    1. UltimateByte avatar

      Step 3: Download the script.
      If the script does not exist, nano creates an empty file...

  20. Florian_LC avatar

    good morning/good evening

    After creating my server under VPS pulseherbeg , when I want to restart my server an error message is displayed : " [ERROR ] Stopping gmod-server: Graceful: sending " quit ": FAIL "
    In addition, my serv does not appear in the Gmod servers, even though it is registered, because it says so in "./gmodserver details".

    Thank you in advance!
    have a nice day/evening

    1. UltimateByte avatar

      1) Never use PulseHeberg, the worst hosting provider
      2) Start by looking at the output from your console and try in debug mode.
      I wrote this guide, start here (and hope you speak 2 words of English)
      https://github.com/GameServerManagers/LinuxGSM/wiki/Troubleshooting

  21. wissyt avatar
    wissyt

    Yo, problems.

    Segmentation fault (core dumped)
    Add " -debug " to the ./srcds_run command line to generate a debug.log to help with solving this problem
    Tuesday 24 October 2017, 21:55:16 (UTC+0200): Server restart in 10 seconds

  22. TheeFoxy avatar
    TheeFoxy

    Hello,
    I have a little problem when I unmount the server :/
    dans la console sa me mets sa

    gmodserver1@Skylyx:~$ ./gmodserver restart
    fetching command_restart.sh...OK
    [ FAIL ] Stopping gmod-server: Check IP: Multiple active network interfaces found.
    Information! Specify the IP you want to use within a LinuxGSM config file.
    location:

    Set ip="0.0.0.0″ to one of the following:
    000.00.000.000 <----IP OF THE MACHINE (normal)
    000.00.0.0 <------IP IN ADDITION
    https://gameservermanagers.com/network-interfaces
    [ OK ] Stopping gmod-server: Graceful: sending "quit": 2: OK
    [ OK ] Stopping gmod-server: LinuxGSM
    gmodserver1@Skylyx:~$

    how can i fix this thanks for your help :p

    I hope to have an answer soon

      1. TheeFoxy avatar
        TheeFoxy

        I thank you for this help ;p I succeeded thanks to you,
        but I still have a problem
        I wanted to install DARKRP so I put them in the folder (gamemods) and did everything that needed to be done.
        but the truck when I want to start a
        ——————————
        ./gmodserver restart
        —————————–
        jai sa que se mets sur la console
        ——————————————–
        gmodserver1@Skylyx:~$ ./gmodserver restart
        [ FAIL ] Stopping gmod-server: Ownership issues found
        Information! The current user (gmodserver1) does not have ownership of the following files:
        User Group File
        root root /home/gmodserver1/serverfiles/garrysmod/gamemodes/darkrp
        root root /home/gmodserver1/serverfiles/garrysmod/gamemodes/darkrp/darkrp.txt
        root root /home/gmodserver1/serverfiles/garrysmod/gamemodes/darkrp/LICENSE.txt
        root root /home/gmodserver1/serverfiles/garrysmod/gamemodes/darkrp/README.md

        so he's going through the whole file until he gets to me.
        ——————————————-
        [ INFO ] Stopping gmod-server: [EN][NEW]Server in Dev Test is already stopped
        gmodserver1@Skylyx:~$
        ——————————————

        I'm sorry to bother you, but it would be a great help.
        thanks again

        1. UltimateByte avatar

          The message is clear. These files in user gmodserver1 do not belong to root. It's time to use the chown command.
          https://terageek.org/tuto/les-serveurs-linux-serie-youtube

  23. Koala avatar
    Koala

    Hello,

    When I install my server, when I go into the nano gmodserver, the file is not at all the same as yours.
    for example:

    version="180409″
    shortname= "gmod "
    gameservername="gmodserver "
    rootdir="$(dirname " $(readlink -f " ${BASH_SOURCE[0]} ") ") "
    selfname="$(basename " $(readlink -f " ${BASH_SOURCE[0]} ") ") "
    servicename="${selfname} "

    There are things like that :/
    What can be done about it?

  24. UltimateByte avatar

    Hello,

    This is because the LinuxGSM config method has changed. The doc is here: https://github.com/GameServerManagers/LinuxGSM/wiki/LinuxGSM-Config

  25. toshiri avatar
    toshiri

    Hello, I have a small problem:
    gmodserver@monvps:/home$ bash linuxgsm.sh gmodserver
    mkdir: cannot create directory '/home/lgsm': Permission denied
    fetching serverlist.csv...FAIL

  26. steam_user avatar
    steam_user

    Hello hello
    I have a small problem, when I want to put my collection in the worshop I make the command
    nano gmodserver
    but inside the file no workshop id folder :/
    sincerely

    1. UltimateByte avatar

      The LinuxGSM config is now in the lgsm/config-lgsm/ folder.
      Ref: https://docs.linuxgsm.com/configuration/linuxgsm-config

  27. zaroch avatar
    zaroch

    Hello ! A little problem on my side during insertion: https://prnt.sc/nk8zin
    If you have a solution, that would be great :D

    1. UltimateByte avatar

      Hello,

      You don't have the "jq" dependency to install... What's wrong?

Leave a Reply