Skip to main content
TRACK A·INSTALL YOUR SERVER·Verified June 2026 · Lua 5.4 · ox_lib 3.x
Learning with an AI assistant?
Copies this lesson plus 2026 ground rules (no lua54 'yes', Cfx.re Portal, correct callback signatures) as a ready-to-paste mentor prompt.

How to set up a FiveM server on Linux

Most production FiveM servers run on Linux. It's cheaper, faster, and once you learn the five-command workflow you'll never go back to a Windows server eating RAM in the background. This lesson takes you from an empty Ubuntu VPS to a joinable server in under an hour.

You'll build
A working FiveM server on a Linux VPS - artifacts, server.cfg, resources, and a screen session to keep it online.
Time
~45 minutes
You need
A Linux VPS with Ubuntu (root access), SSH client, a Cfx.re account, and a license key from portal.cfx.re.
You'll learn
Why Linux for production, the artifacts vs data split, server.cfg line by line, screen to keep the server alive, and the resource-install workflow.
BEFORE YOU START

Build it

Update the server

All system packages are current.

Before installing anything, update Ubuntu:

bash
apt update && apt upgrade -y
apt install wget git screen -y

This downloads the latest package lists and upgrades everything. It prevents "package not found" errors later.

Create the folder structure

Two clean folders: one for binaries, one for your data.
bash
mkdir -p /home/fxserver
mkdir -p /home/server-data
  • /home/fxserver/ - the FiveM server binaries (the engine). You update this folder when FiveM releases a new build.
  • /home/server-data/ - your content: resources/ folder and server.cfg. This is what you back up and version-control.

Keeping them separate means updating the engine never touches your scripts.

Download and extract the artifacts

FXServer is ready to run.

Go to the Linux artifacts page and copy the URL for the latest build (not the green "recommended" one):

text
https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/

Download and extract:

bash
cd /home/fxserver
wget -O fx.tar.xz <paste-the-download-url-here>
tar -xf fx.tar.xz
rm fx.tar.xz

Artifacts are the actual FiveM server software. Scripts don't work without them - they're the engine everything runs on.

Get the server data

The resources folder and starter config are ready.
bash
cd /home/server-data
git clone https://github.com/citizenfx/cfx-server-data.git .

Git is a tool that downloads code from GitHub. The cfx-server-data repo contains the starter resources (chat, mapmanager, spawnmanager) and an example server.cfg.

Write your server.cfg

The server has a name, endpoints, license, and resources.

Open /home/server-data/server.cfg and replace everything with:

bash
## --- Endpoints (how players connect) ---
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
 
## --- Server identity ---
sv_hostname "My Linux FiveM Server"
sv_maxclients 32
onesync on
 
## --- License key (REQUIRED - server won't boot without it) ---
sv_licenseKey "PASTE_YOUR_KEY_HERE"
 
## --- Built-in resources ---
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
 
## --- Admin permissions ---
add_ace group.admin command allow
add_principal identifier.license:YOUR_LICENSE_HERE group.admin

ensure tells FiveM: "start this resource when the server boots." Resources listed higher start first.

Start the server

Players can connect.
bash
cd /home/server-data
bash /home/fxserver/run.sh +exec server.cfg

This runs the FXServer binary and hands it your config. The console prints each resource starting in order, then "Server ready."

Keep the server alive with screen

The server stays online after you close SSH.

When you close your SSH terminal, any process running in it dies. screen fixes this:

bash
# screen already installed in Step 1
screen -S fivem
cd /home/server-data
bash /home/fxserver/run.sh +exec server.cfg

Now press Ctrl+A, then D to detach. The server keeps running. To rejoin later:

bash
screen -r fivem

Installing resources - the workflow

Every resource follows the same five steps:

  1. Download the resource and place it in /home/server-data/resources/
  2. Read the README - note dependencies, framework, and SQL files
  3. Add dependencies first, then add ensure resource_name to server.cfg AFTER its dependencies
  4. Import any .sql files using HeidiSQL or the mysql command line
  5. Restart the server or run ensure resource_name in the console
ToolWhat it does
Ubuntu 22.04+The operating system
txAdminWeb dashboard for server management (starts at :40120)
MariaDBThe database that stores player data
oxmysqlThe connector between FiveM and MariaDB
HeidiSQLDesktop tool to view and edit the database
GitHubWhere resources are hosted and version-controlled
VS CodeCode editor for editing configs and scripts

Common failures

What you seeWhat it meansHow to fix it
Server won't start - "Invalid license key"Key is wrong or missingRe-copy from portal.cfx.re. No extra spaces
"Could not find resource X"Resource folder missing or misspelledCheck /home/server-data/resources/X/fxmanifest.lua exists
Players can't connect - "Connection timed out"Port 30120 blocked by firewallRun ufw allow 30120/tcp and ufw allow 30120/udp. Check your VPS provider's firewall too
Server dies when you close SSHYou didn't use screenAlways start the server inside screen -S fivem
Permission denied when running run.shScript isn't executableRun chmod +x /home/fxserver/run.sh
apt: command not foundYou're not on Ubuntu/DebianThis guide is for Ubuntu. For CentOS/RHEL, use yum instead of apt