Garry's Mod Wiki

Revision Difference

Linux_Dedicated_Server_Hosting#518686

<cat>Play.Hosting</cat> This article will handle as many aspects as possible about hosting a Garry's Mod server on Linux. **This article has been written for Debian and derivatives (Ubuntu, ChromiumOS, Mint...) so you may need to do some conversion on other distributions** If you want a more automated solution with many built-in tools, easy support for multiple servers, etc, just use https://linuxgsm.com/lgsm/gmodserver/ instead # Requirements Make sure you meet the following requirements before you begin: * A user to run the server as ('steam' is recommended, with home directory /home/steam) * Enough disk space for the content you wish to install * An open command-line terminal running as the user 'steam' (`su - steam`) or an SSH session with steam as logged in user. * Experience with basic Linux command-line usage. # Installing SteamCMD SteamCMD is needed to download and update the Garry's Mod server files. Follow the [Valve Developer Wiki](https://developer.valvesoftware.com/wiki/SteamCMD#Linux) for recommendations on how to install SteamCMD. ## 64-bit Systems If you get "*/linux32/steamcmd: No such file or directory" error, this is most likely because you do not have the required 32-bit libraries. Go here for more information on how to fix this: https://developer.valvesoftware.com/wiki/SteamCMD#32-bit_libraries_on_64-bit_Linux_systems # Installing Garry's Mod <validate>Does the script provided here work when SteamCMD is installed from a package repository?</validate> The following script will download the latest version of Garry's Mod for you with a single command. First, lets go to our home directory. ``` cd ~ ``` Then, we need to download the script: ``` wget http://pastebin.com/raw/CRmMbJQA -O ./update_gmod.sh ``` Before we can run this file, we need to give it 'execute' rights. This is done with the following command: ``` chmod +x ./update_gmod.sh ``` Before we can run it correctly, we need to convert it from dos format to unix format: ``` dos2unix ./update_gmod.sh ``` Now, lets update the server ``` ./update_gmod.sh ``` The server will now download the necessary content. Steam will show you the percentage of progress it is making with the download. If you receive an error such as &lt;code class="inline"&gt;/home/steam/update_gmod.sh: line 25: ./bin/steamcmd.sh: No such file or directory&lt;/code&gt; open ./update_gmod.sh in an editor and change the line under "# Call SteamCMD with the app ID we provided and tell it to install" to the following: If you receive an error such as <code class="inline">/home/steam/update_gmod.sh: line 25: ./bin/steamcmd.sh: No such file or directory</code> open ./update_gmod.sh in an editor and change the line under "# Call SteamCMD with the app ID we provided and tell it to install" to the following: ``` steamcmd +login anonymous +force_install_dir "$HOME/$DIR" +app_update $APP_ID validate +quit ``` # Adding content Of course, we want to be able to use stuff from Team Fortress 2, Counter-Strike: Source and other supported games. Using the script above, this is simple process. However, since we want to save on download time, we are going to put all this content in a separate folder, so if we have 5 servers, we only need to update the content once if a content update gets released. Now we are going to modify the script mentioned <page text="above">#Installing_Garry's_Mod</page>. Add the following line where it says "`Add any additional servers here`". Here, we add Team Fortress 2. ``` update_server 232250 "content/tf2" ``` Now, when we run `update_gmod.sh` the script will verify (and, if required, update) Garry's Mod (since we downloaded it in the step above) and then install Team Fortress 2 in `~/content/tf2`. For a list of IDs for the servers, you can have a look at the [Valve Developer Community page](https://developer.valvesoftware.com/wiki/Dedicated_Servers_List). Remember that you can theoretically download any game here using its ID, but with these dedicated servers you don't need to login using your steam account. # Starting the server To start the server, we run the file called srcds_run, which is located in the root directory of each server. The command below starts the server with 12 slots on gm_flatgrass. ``` ~/server_1/srcds_run -game garrysmod +maxplayers 12 +map gm_flatgrass ``` The script (srcds_run) will keep the server alive, should it crash, but it won't restart when you restart linux and if you close the terminal the server will close. We will fix this later on in this article. # Updating the server To update the server, or to update the content, we simply call our download script. You need to make sure your servers are off, or else the update will fail. Update our scripts by just calling this (from the home directory) ``` ./update_gmod.sh ``` # Keeping the server alive after a reboot To keep the server alive we use crontab. We add an entry to crontab which will call srcds_run when the server has loaded. Open crontab ``` crontab -e ``` Now, add the following line at the end ``` @reboot /home/steam/server_1/srcds_run -game garrysmod +maxplayers 12 +map gm_flatgrass ``` Now save the file. Usually crontab opens in nano so the commands would, again, be <key>Ctrl|O</key>, <key>Enter</key>, <key>Ctrl|X</key>. Now, after you reboot the linux server, the Garry's Mod Server will auto start. ## Additional notes Of course, there are better ways of keeping your server alive, but they can become quite complex in no-time so they are not discussed here. If you want to know more, Google around or ask on Facepunch. # Troubleshooting ## 32-bit binaries If you're running a 64-bit version of Linux, you need 32 bit binaries, since SteamCMD is only available as 32 bit. If you get the error message ``` ./steamcmd.sh: line 29: /home/$USER/Steam/linux32/steamcmd: No such file or directory ``` then you are most likely running 64 a bit system and missing 32 bit libraries. To do so, you need to install **ia32-libs**. To do so, run the following bit of code: ``` dpkg --add-architecture i386 apt-get update apt-get install ia32-libs or apt-get install lib32ncurses5 lib32z1 ``` The package is big (~200MB isn't uncommon) and has a lot of dependancies so it may take some time. For other linux distrubutions, see the [ Valve wiki article ](https://developer.valvesoftware.com/wiki/SteamCMD#32-bit_libraries_on_64-bit_Linux_systems) ## 'GLIBC_2.15' not found If you get the error message ``` Failed to open dedicated_srv.so (/lib/i386-linux-gnu/libm.so.6: version `GLIBC_2.15' not found (required by bin/dedicated_srv.so)) ``` You most likely have outdated GLIBC libraries and will need to update them. This has happened because you chose to use a different distribution (or version of a distribution) than the one Valve used to create the tools. Those tools are expecting components from that Linux distribution. (See 'Notice' above!) To deal with this without updating to Ubuntu 12.04 32-bit or later, run the following bit of code: ``` wget <nowiki>http://security.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6_2.15-0ubuntu10.11_i386.deb</nowiki> dpkg -x libc6_2.15-0ubuntu10.11_i386.deb tmp/ cd tmp/lib/i386-linux-gnu/ cp * /your-garrysmod-directory/bin/ ``` For CentOS you need to install the [EPEL Repo](http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x) and dpkg first: ``` yum install dpkg ``` Alternatively you could switch to: * Ubuntu Server 12.04+ * CentOS 7 These distros have been confirmed working and are the most supported. ## Addons Not Working As you are getting your server up and running you may notice some issues with particular addons not working. This problem seems to be affecting legacy addons with folders containing capitals. To fix this issue it may be required to change all directories to lowercase names and all Lua code pointing to these directories accordingly.