Setup a Linux Server

From GT-MP
Jump to: navigation, search


Setup a Linux Server - Version 1

Installing mono

Dialog-warning.png Mono version 5.8 is required to get your server working. Please checkout Setting Up a Development Environment on Linux to get the details.

Ubuntu and derivatives

Latest Ubuntu releases

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update && sudo apt-get install mono-complete

Outdated Ubuntu releases (Ubuntu 12.04/12.10)

echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list

Debian 9

sudo apt install apt-transport-https dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-complete

Debian 8

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo apt install apt-transport-https
echo "deb https://download.mono-project.com/repo/debian stable-jessie main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-complete

CentOS 7, Fedora 19 (and later), and derivatives

# Run all these commands in a root shell, or as an alternative, you can use sudo
yum install yum-utils
rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
yum-config-manager --add-repo http://download.mono-project.com/repo/centos/
yum update && yum install mono-complete

Other distributions

Please refer to the official mono documentation

Setting up the server

Debian, Ubuntu, and derivatives

# ~/server = /root/server/
sudo apt-get install unzip
cd /tmp
Upload the previously downloaded 'Server' folder from here (https://gt-mp.net/file-downloads/)
unzip GT-MP-Server.zip -d ~/server
cd ~/server
chmod +x GrandTheftMultiplayer.Server.exe
mono GrandTheftMultiplayer.Server.exe
# Firewall commands (iptables only) (dont forget to save the rule after adding it)
iptables -A INPUT -p udp --dport 4499 -j ACCEPT

CentOS 7, Fedora 19 (and later), and derivatives

# ~/server = /root/server/
sudo yum install unzip
cd /tmp
Upload the previously downloaded 'Server' folder from here (https://gt-mp.net/file-downloads/)
sudo unzip GT-MP-Server.zip -d ~/server
cd ~/server 
chmod +x GrandTheftMultiplayer.Server.exe
mono GrandTheftMultiplayer.Server.exe
# Firewall commands (iptables only) (dont forget to save the rule after adding it)
iptables -A INPUT -p udp --dport 4499 -j ACCEPT

Using screen for running server in background

Setting up

Debian, Ubuntu and derivatives

sudo apt-get install screen

CentOS 6.x/7.x

yum install screen

Starting the server

screen -dmS GTAMULTIPLAYERSERVER -L bash -c 'cd ~/server && mono GrandTheftMultiplayer.Server.exe' &
# Parameter explanation
# screen -dmS = starts a separate shell without directly opening an interface towards it (detached mode). The S param defines a session name for the newly created session, so that it is easier to manage in the future.
# screen -L = basically logs whatever error that is shown by the server through the separate shell into a file for easier reference in the future.
# !IMPORTANT!
# Log output will be saved as screenlog._number_ in the server directory.
# &: IS IMPORTANT IF YOU WANT TO TERMINATE THE PROCESS GRACEFULLY

Stopping the server

RECOMMENDED:

kill $(ps h --ppid $(screen -ls | grep GTAMULTIPLAYERSERVER | cut -d. -f1) -o pid)

NOT RECOMMENDED: It does not shut down the server gracefully

screen -S GTAMULTIPLAYERSERVER -X quit

Troubleshooting

  • System.Net.WebException: Error: SecureChannelFailure (The authentication or decryption has failed.)

First, Make sure that the masterserver line looks exactly like this: <masterserver>http://master.mta-v.net/api/</masterserver> If that does not solve it, make sure ca-certificates-mono is installed. Other possible fixes: mozroots --import --ask-remove


  • System.NotImplementedException: The request feature is not implemented (LinuxUnicastIPAddress error)

Make sure you are not running an old mono version mono -V, anything above 4.5.2 should work fine.


  • Missing method .ctor in assembly or any kind of unimplemented feature error

Make sure you are not running an outdated mono version. At the time of this writing, the current stable mono version available is 4.6.1 and is confirmed to be working perfectly fine. To check the currently installed mono version: mono -V


Source: Setting up the Server on Linux by julice



Setup a Linux Server - Version 2

Requirements

  • A Linux Distrubition that support Mono

Installation

Step 1 - Install Mono

First you need to intall Mono on your machine. Install instructions can you find here.

Instead of installing all mono packages here is a minimal set of all packages that are needed to run gt-mp

apt-get install mono-4.0-gac mono-gac mono-mcs mono-runtime mono-runtime-common mono-runtime-sgen \
libmono-accessibility4.0-cil libmono-btls-interface4.0-cil libmono-corlib4.5-cil libmono-csharp4.0c-cil \
libmono-data-tds4.0-cil libmono-i18n-west4.0-cil libmono-i18n4.0-cil libmono-microsoft-csharp4.0-cil \
libmono-posix4.0-cil libmono-security4.0-cil libmono-system-configuration4.0-cil \
libmono-system-core4.0-cil libmono-system-data4.0-cil libmono-system-drawing4.0-cil \
libmono-system-enterpriseservices4.0-cil libmono-system-numerics4.0-cil \
libmono-system-runtime-serialization-formatters-soap4.0-cil libmono-system-runtime-serialization4.0-cil \
libmono-system-security4.0-cil libmono-system-servicemodel-internals0.0-cil \
libmono-system-transactions4.0-cil libmono-system-windows-forms4.0-cil libmono-system-xml4.0-cil \
libmono-system4.0-cil libmono-webbrowser4.0-cil

Step 2 - Install Screen (optional)

You need this that running the server in the background. Even if you log out from the machine.

Use this command to install Screen:

apt-get install screen

Step 3 - Download the Server Files

You can find the Download Link here: Download Page

After the Download finished, you need to extract the files of the archive.

Step 4 - Starting the Server

Before we can start the Server, we need to give the Server file permission to start.

We do that with this command:

chmod 755 GrandTheftMultiplayer.Server.exe


After that, we need to open an screen with this command (if you installed screen):

screen -S gta

In that case gta mean the screen name


After a new screen is opened, can we start the server with this command

mono GrandTheftMultiplayer.Server.exe

After you entered this command, the server should start.

Now we can leave the Screen with the following key combination (if you installed screen)

STRG + A + D

Alternative Step 4 - Starting the Server

Most modern Linux distributions uses systemd now to start services. Create a file with the name gt-mp.service and the following content:

[Unit]
Description=gt-mp multiplayer server
Wants=network.target
After=network.target

[Service]
ExecStart=/usr/bin/mono GrandTheftMultiplayer.Server.exe
WorkingDirectory=/devel/gta/
Restart=always
StartLimitInterval=90
StartLimitBurst=3

[Install]
WantedBy=multi-user.target

Change the WorkingDirectory option to where you unpacked the server files.

Alter or remove the options Restart, StartLimitInterval and StartLimitBurst

Copy the file to /etc/systemd/system

Load the configuration with

systemctl daemon-reload

Start the server

sytstemctl start gt-mp

Status can be seen with

systemctl status gt-mp

Logs can be seen with

journalctl -u gt-mp

To monitor the log enter

journalctl -f -u gt-mp

Information

More informations about Screen can you find here.

More informations about systemd under https://www.freedesktop.org/wiki/Software/systemd/