Getting Started with Server: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Update how to get files)
 
(51 intermediate revisions by 18 users not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==
*[[Ru:Getting Started with Server]]


This brief tutorial will show you how to run your server on both Windows and Linux distributions.
This brief tutorial will show you how to run your server on both Windows and Linux distributions.
Line 6: Line 8:
So make sure to have done the ports forwarding on your router process and have also unblocked the ports on your firewall before running the server.  
So make sure to have done the ports forwarding on your router process and have also unblocked the ports on your firewall before running the server.  


=Requirements=
=Windows=
For a hassle-less installation and operation, the latest VC Redist is recommended to have.
==Prerequisite==
For a hassle-free installation and operation, it is recommended to have the latest VC Redist.


[https://aka.ms/vs/15/release/VC_redist.x64.exe Microsoft Visual C++ Redistributable 2017]
[https://aka.ms/vs/15/release/VC_redist.x64.exe Microsoft Visual C++ Redistributable 2017]


=Bridge=
== Setting up the Server ==
The following tutorial is found on [https://wiki.gtanet.work/index.php?title=Setting_up_the_Bridge_on_Linux/Windows Setting up the Bridge on Linux/Windows]
 
=== How to Get Server Files ===


=Windows=
* '''Download''' the RAGE Multiplayer Client ([https://cdn.rage.mp/public/files/RAGEMultiplayer_Setup.exe Download Here])
1. Download the latest [https://cdn.rage.mp/client/updater.exe updater.exe]
* '''Edit''' the XML configuration: Change '''prerelease''' to '''prerelease_server''' in '''RAGEMP/config.xml'''.
* '''Run''' the updater: Execute '''updater.exe'''.
* '''Retrieve Server Files''': Locate and take the '''server_files''' folder.
* '''Revert Configuration''': Change back from '''prerelease_server''' to '''prerelease''' in '''RAGEMP/config.xml'''.
* '''Final Update''': Run '''updater.exe''' again to restore the proper client version.
 
=== Starting the Server ===
* Navigate to the '''server_files''' folder.
* Execute '''ragemp-server.exe'''.
* Connect locally using the default IP: '''127.0.0.1:22005'''.


2. Run the downloaded '''updater.exe'''
==== Additional Information ====
* For detailed server settings, refer to the [https://wiki.rage.mp/index.php?title=Server_settings Server Settings] page on the RAGE Multiplayer wiki.


3. Launch '''server.exe''' and you should be able to connect to it.
==Next step==
[[Getting Started with Development]]


=Linux=
=Linux=
==Prerequisite==
It's recommended to use Debian or Ubuntu to set up a server if you're new to Linux.
*Debian 10 or above [https://distrowatch.com/table.php?distribution=debian See more]
*Ubuntu 18.10 or above [https://distrowatch.com/table.php?distribution=ubuntu See more]
*An OS that supports glibc v2.28
===Ubuntu===
<syntaxhighlight lang="bash">
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt install libstdc++6
</syntaxhighlight>
===Debian===
<syntaxhighlight lang="bash">
echo 'deb http://httpredir.debian.org/debian testing main contrib non-free' > /etc/apt/sources.list
apt update && apt install -y -t testing libstdc++6
</syntaxhighlight>
==Setting up server==
This bash snippet should automate the server installation.
This bash snippet should automate the server installation.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
# Downloading server
# Downloading server
cd /tmp
wget https://cdn.rage.mp/updater/prerelease/server-files/linux_x64.tar.gz
wget https://cdn.rage.mp/lin/ragemp-srv.tar.gz


# Extract the server files
# Extract the server files
tar -xzf ragemp-srv.tar.gz
tar -xzf linux_x64.tar.gz
mv ragemp-srv ~/ragemp-srv
 
# Accessing the directory
cd ragemp-srv
 
# Set executable permission
chmod +x ragemp-server


# Run the server
# Run the server
cd ~/ragemp-srv
./ragemp-server
chmod +x server
</syntaxhighlight>
./server


# Firewall commands (iptables only) (dont forget to save the rule after adding it)
==Launching the server as a daemon (systemd)==
iptables -A INPUT -p udp --dport 22005 -j ACCEPT
If you want to launch the server as a daemon on the latest version of Ubuntu/Debian/CentOS, you need to follow these steps:
iptables -A INPUT -p tcp --dport 22006 -j ACCEPT
1. We recommend move your server to /opt
e.g '''mv ./ragemp-srv /opt/'''
2. Create the systemd unit (e.g /etc/systemd/system/rageserv.service) and enter this config:


<syntaxhighlight lang="ini">
[Unit]
Description=RAGE-MP Dedicated server
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
; not safe, change root to another user
User=root
WorkingDirectory=/opt/ragemp-srv
ExecStart=/opt/ragemp-srv/ragemp-server
[Install]
WantedBy=multi-user.target
</syntaxhighlight>
</syntaxhighlight>


==Setting up==
'''Important: If you have not moved the directory, you need to edit WorkingDirectory and ExecStart with new absolute paths.'''
===Installing screen===
For running the server in background, we recommend using screen mainly for its ease of use
3. After saving the new unit we recommend you to update your systemd unit's list.
4. Finally! Now you can enable and run the unit via these commands:
#  systemctl enable rageserv
#  systemctl start rageserv
If you want to watch status of your server you need enter:
<syntaxhighlight lang="bash">
systemctl status rageserv
</syntaxhighlight>


====Debian based (Ubuntu & derivatives)====
If you want to restart your server you need to enter:
<syntaxhighlight lang="bash">
systemctl restart rageserv
</syntaxhighlight>
More commands and other details can be found [https://www.freedesktop.org/software/systemd/man/systemctl.html#Unit%20File%20Commands here.]
 
==Installing screen (Optional)==
For running the server in the background, we recommend using screen, mainly for its ease of use.
 
===Debian based (Ubuntu & derivatives)===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo apt-get install screen
sudo apt-get install screen
</syntaxhighlight>
</syntaxhighlight>


====CentOS 6.x/7.x====
===CentOS 6.x/7.x===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
yum install screen
yum install screen
Line 60: Line 137:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
screen -dmS GTASERVER -L bash -c 'cd ~/srv && ./server' &
screen -dmS GTASERVER -L bash -c 'cd ~/srv && ./server' &
# 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
</syntaxhighlight>
</syntaxhighlight>
<u>Parameter explanation:</u>
* <syntaxhighlight lang="bash" inline>screen -dmS</syntaxhighlight> starts a separate shell without directly opening an interface towards it (detached mode). The <tt>S</tt> param defines a session name for the newly created session (in this case <code>GTASERVER</code>), so that it is easier to manage in the future.
* <syntaxhighlight lang="bash" inline>screen -L</syntaxhighlight> 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 <code>screenlog.''_number_''</code> in the server directory.
* <code>&</code> '''IS IMPORTANT''' IF YOU WANT TO TERMINATE THE PROCESS GRACEFULLY.


===Stopping the server===
===Stopping the server===
To stop the server, there's usually two ways to do that, one that we call a '''graceful''' shutdown that sends the server a signal for termination and the other, well, a '''crash''' since it does not allow the code to run through the termination process correctly.
There are usually two ways to stop the server; One that we call a '''graceful''' shutdown that sends the server a signal for termination and the other, well, a '''crash''' since it does not allow the code to run through the termination process correctly.


'''RECOMMENDED:'''
'''RECOMMENDED:'''
Line 84: Line 160:
=Troubleshooting=
=Troubleshooting=
==Linux==
==Linux==
* '''Launching the server throws a the following message:'''
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./server: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by ./server)
./server: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by ./server)
</syntaxhighlight>
</syntaxhighlight>


Solution ('''Debian based (Ubuntu & derivatives)'''):
Make sure GCC/G++ 6 or newer is installed, follow the [[#Prerequisite_2|Prerequisite]].
<syntaxhighlight lang="bash">
 
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
= See also =
sudo apt-get update
* [[Server settings]]
sudo apt-get install gcc-6 g++-6
{{ScriptingTutorials}}
</syntaxhighlight>
 
[[Category:Tutorials]]

Latest revision as of 14:03, 20 January 2024

Introduction

This brief tutorial will show you how to run your server on both Windows and Linux distributions.

By default, the server makes use of port 22005 UDP for server access and the port after (here 22006) for the HTTP server hosting the client packages for the clients to download from.
So make sure to have done the ports forwarding on your router process and have also unblocked the ports on your firewall before running the server.

Windows

Prerequisite

For a hassle-free installation and operation, it is recommended to have the latest VC Redist.

Microsoft Visual C++ Redistributable 2017

Setting up the Server

How to Get Server Files

  • Download the RAGE Multiplayer Client (Download Here)
  • Edit the XML configuration: Change prerelease to prerelease_server in RAGEMP/config.xml.
  • Run the updater: Execute updater.exe.
  • Retrieve Server Files: Locate and take the server_files folder.
  • Revert Configuration: Change back from prerelease_server to prerelease in RAGEMP/config.xml.
  • Final Update: Run updater.exe again to restore the proper client version.

Starting the Server

  • Navigate to the server_files folder.
  • Execute ragemp-server.exe.
  • Connect locally using the default IP: 127.0.0.1:22005.

Additional Information

  • For detailed server settings, refer to the Server Settings page on the RAGE Multiplayer wiki.

Next step

Getting Started with Development

Linux

Prerequisite

It's recommended to use Debian or Ubuntu to set up a server if you're new to Linux.

  • Debian 10 or above See more
  • Ubuntu 18.10 or above See more
  • An OS that supports glibc v2.28

Ubuntu

sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt install libstdc++6

Debian

echo 'deb http://httpredir.debian.org/debian testing main contrib non-free' > /etc/apt/sources.list
apt update && apt install -y -t testing libstdc++6

Setting up server

This bash snippet should automate the server installation.

# Downloading server
wget https://cdn.rage.mp/updater/prerelease/server-files/linux_x64.tar.gz

# Extract the server files
tar -xzf linux_x64.tar.gz

# Accessing the directory
cd ragemp-srv

# Set executable permission
chmod +x ragemp-server

# Run the server
./ragemp-server

Launching the server as a daemon (systemd)

If you want to launch the server as a daemon on the latest version of Ubuntu/Debian/CentOS, you need to follow these steps:

1. We recommend move your server to /opt e.g mv ./ragemp-srv /opt/

2. Create the systemd unit (e.g /etc/systemd/system/rageserv.service) and enter this config:

[Unit]
Description=RAGE-MP Dedicated server
After=network.target
StartLimitIntervalSec=0
 
[Service]
Type=simple
Restart=always
RestartSec=1
; not safe, change root to another user
User=root
WorkingDirectory=/opt/ragemp-srv
ExecStart=/opt/ragemp-srv/ragemp-server
 
[Install]
WantedBy=multi-user.target

Important: If you have not moved the directory, you need to edit WorkingDirectory and ExecStart with new absolute paths.

3. After saving the new unit we recommend you to update your systemd unit's list.

4. Finally! Now you can enable and run the unit via these commands:

  1. systemctl enable rageserv
  2. systemctl start rageserv

If you want to watch status of your server you need enter:

systemctl status rageserv

If you want to restart your server you need to enter:

systemctl restart rageserv

More commands and other details can be found here.

Installing screen (Optional)

For running the server in the background, we recommend using screen, mainly for its ease of use.

Debian based (Ubuntu & derivatives)

sudo apt-get install screen

CentOS 6.x/7.x

yum install screen

Starting the server

screen -dmS GTASERVER -L bash -c 'cd ~/srv && ./server' &

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 (in this case GTASERVER), 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

There are usually two ways to stop the server; One that we call a graceful shutdown that sends the server a signal for termination and the other, well, a crash since it does not allow the code to run through the termination process correctly.

RECOMMENDED:

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

NOT RECOMMENDED: It does not shut down the server gracefully

screen -S GTASERVER -X quit

Troubleshooting

Linux

./server: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by ./server)

Make sure GCC/G++ 6 or newer is installed, follow the Prerequisite.

See also