FiveM is a multiplayer game server that allows you to play on customized dedicated servers. It was specifically designed for creativity. You can create your server and make your dreams come true. It provides a set of tools to personalize the gameplay experience of your server. With FiveM, you can make anything, including roleplay, drifting, racing, deathmatch, or something completely original.
This tutorial will show you how to install FiveM on Ubuntu 20.04.
Prerequisites
- A fresh Ubuntu 20.04 Server (at least 2GB RAM)
- A valid domain name pointed to your server IP
- A root password configured on your server
Step 1 – Install Required Dependencies
Before starting, you will need to install some dependencies on your server. You can install all of them with the following commands:
apt-get update -y
apt-get install screen wget git -y
Once all the packages are installed, you can proceed to the next step.
Step 2 – Install and Configure FiveM
First, create a directory for FiveM and download the latest version of FiveM inside the directory:
mkdir ~/fivem_server cd ~/fivem_server wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/6683- 0c5d71ad77873c159d7542a7e8314d9696c1b55b/fx.tar.xz
Once the download is completed, extract the downloaded file with the following command:
tar -xvf fx.tar.xz
Next, you must download the CFX server data to your system. You can download it with the following command:
git clone https://github.com/citizenfx/cfx-server-data ~/fivem_resources
Next, you will need to create a FiveM configuration file.
You can create it with the following command:
nano ~/fivem_resources/server.cfg
Add the following lines, including your FiveM Licence:
# Only change the IP if you’re using a server with multiple network interfaces, otherwise change the port only. endpoint_add_tcp "0.0.0.0:30120” endpoint_add_udp "0.0.0.0:30120” # These resources will start by default. ensure mapmanager ensure chat ensure spawnmanager ensure sessionmanager ensure fivem ensure hardcap ensure rconlog ensure scoreboard # This allows players to use scripthook-based plugins such as the legacy Lambda Menu. # Set this to 1 to allow scripthook. Do note that this does _not_ guarantee players won’t be able to use external plugins. sv_scriptHookAllowed 0 # Uncomment this and set a password to enable RCON. Make sure to change the password - it should look like rcon_password "YOURPASSWORD” #rcon_password "” # A comma-separated list of tags for your server. # For example: # - sets tags "drifting, cars, racing” # Or: # - sets tags "roleplay, military, tanks” sets tags "default” # Set an optional server info and connecting banner image url. # Size doesn’t matter, any banner sized image will be fine. #sets banner_detail "https://url.to/image.png” #sets banner_connecting "https://url.to/image.png” # Set your server’s hostname sv_hostname "FXServer, but unconfigured” # Nested configs! #exec server_internal.cfg # Loading a server icon (96×96 PNG file) #load_server_icon myLogo.png # convars which can be used in scripts set temp_convar "hey world!” # Uncomment this line if you do not want your server to be listed in the server browser. # Do not edit it if you *do* want your server listed. #sv_master1 "” # Add system admins add_ace group.admin command allow # allow all commands add_ace group.admin command.quit deny # but don’t allow quit add_principal identifier.steam:110000100000000 group.admin # add the admin to the group # Hide player endpoints in external log output. sv_endpointprivacy true # Server player slot limit (must be between 1 and 32, unless using OneSync) sv_maxclients 32 # License key for your server (https://keymaster.fivem.net) sv_licenseKey i1mqzvi2eukui85p8cb0uddanqsru2lk
Save and close the file when you are finished.
Next, you can start the FiveM server with the following command:
cd ~/fivem_resources && bash ~/fivem_server/run.sh +exec server.cfg
Once the server has started successfully, you should get the following output:
Note: This process will take several minutes to start
[------------------------------------------------------------------------------------------------------ --------------------------------] 0/315Server license key authentication succeeded. Welcome! Authenticating with Nucleus... [#####------------------------------------------------------------------------------------------------- -------------------------------] 11/315 fff cccc ff xx xx rr rr eee cc ffff xx rrr r ee e cc ff xx ... rr eeeee ccccc ff xx xx ... rr eeeee Authenticated with cfx.re Nucleus: https://hitj-e8q3pd.users.cfx.re/ [###############################----------------------------------------------------------------------------- -------------------------] 74/315-- [server notice: tebex_not_set] ================ Monetize your server using Tebex! Visit https://tebex.io/fivem for more info. ================
Press CTRL + C to stop the server.
Step 3 – Create a Systemd Service File for FiveM
Creating a systemd service file to manage the FiveM service is a good idea. You can create it with the following command:
nano /lib/systemd/system/fivem.service
Add the following lines:
[Unit] Description=FiveM server [Service] Type=forking User=root ExecStart=/usr/bin/fivem_start.sh [Install] WantedBy=multi-user.target
Save and close the file, then create a FiveM start script:
nano /usr/bin/fivem_start.sh
Add the following lines: #!/bin/bash screen -dm bash -c 'cd /root/fivem_resources && bash /root/fivem_server/run.sh +exec server.cfg'
Save and close the file, then set proper permission:
chmod +x /usr/bin/fivem_start.sh
Next, reload the systemd daemon with the following command:
systemctl daemon-reload
Next, start FiveM and enable it to start at system reboot:
systemctl start fivem systemctl enable fivem
You can verify the status of FiveM with the following command:
systemctl status five
You should get the following output:
-
fivem.service - FiveM server
Loaded: loaded (/lib/systemd/system/fivem.service; disabled; vendor preset: enabled) Active: active (running) since Wed 2021-01-13 15:09:13 UTC; 6s ago Process: 24132 ExecStart=/usr/bin/fivem_start.sh (code=exited, status=0/SUCCESS) Main PID: 24136 (screen) Tasks: 67 (limit: 4691) Memory: 48.1M CGroup: /system.slice/fivem.service ├─24136 SCREEN -dm bash -c cd /root/fivem_resources && bash /root/fivem_server/run.sh +exec server.cfg ├─24148 /root/fivem_server/alpine/opt/cfx-server/ld-musl-x86_64.so.1 -- library-path /root/fivem_server/alpine/usr/lib/v8/:/root/f> └─24151 /root/fivem_server/alpine/opt/cfx-server/ld-musl-x86_64.so.1 -- library-path /root/fivem_server/alpine/usr/lib/v8/:/root/f> Jan 13 15:09:13 ubuntu2004 systemd[1]: Starting FiveM server... Jan 13 15:09:13 ubuntu2004 systemd[1]: Started FiveM server.
By default, FiveM listens on port 30120. You can check it with the following command:
ss -antpl | grep 30120
You should get the following output:
LISTEN 0 128 0.0.0.0:30120 0.0.0.0:* users:(("ld-musl-x86_64.",pid=24148,fd=57))
Conclusion
Congratulations! You have successfully installed and configured a FiveM game server on Ubuntu 20.04. You can now download the FiveM client on your desktop system and play using FiveM on your virtual private server from Atlantic.Net!
Learn more about our VPS hosting services and Virtual private servers.