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.
Build it
Update the server
Before installing anything, update Ubuntu:
apt update && apt upgrade -y
apt install wget git screen -yThis downloads the latest package lists and upgrades everything. It prevents "package not found" errors later.
Create the folder structure
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 andserver.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
Go to the Linux artifacts page and copy the URL for the latest build (not the green "recommended" one):
https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/Download and extract:
cd /home/fxserver
wget -O fx.tar.xz <paste-the-download-url-here>
tar -xf fx.tar.xz
rm fx.tar.xzArtifacts are the actual FiveM server software. Scripts don't work without them - they're the engine everything runs on.
Get the server data
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
Open /home/server-data/server.cfg and replace everything with:
## --- 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.adminensure tells FiveM: "start this resource when the server boots." Resources listed higher start first.
Start the server
cd /home/server-data
bash /home/fxserver/run.sh +exec server.cfgThis 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
When you close your SSH terminal, any process running in it dies. screen fixes this:
# screen already installed in Step 1
screen -S fivem
cd /home/server-data
bash /home/fxserver/run.sh +exec server.cfgNow press Ctrl+A, then D to detach. The server keeps running. To rejoin later:
screen -r fivemInstalling resources - the workflow
Every resource follows the same five steps:
- Download the resource and place it in
/home/server-data/resources/ - Read the README - note dependencies, framework, and SQL files
- Add dependencies first, then add
ensure resource_nameto server.cfg AFTER its dependencies - Import any
.sqlfiles using HeidiSQL or the mysql command line - Restart the server or run
ensure resource_namein the console
Recommended modern stack
| Tool | What it does |
|---|---|
| Ubuntu 22.04+ | The operating system |
| txAdmin | Web dashboard for server management (starts at :40120) |
| MariaDB | The database that stores player data |
| oxmysql | The connector between FiveM and MariaDB |
| HeidiSQL | Desktop tool to view and edit the database |
| GitHub | Where resources are hosted and version-controlled |
| VS Code | Code editor for editing configs and scripts |
Common failures
| What you see | What it means | How to fix it |
|---|---|---|
| Server won't start - "Invalid license key" | Key is wrong or missing | Re-copy from portal.cfx.re. No extra spaces |
| "Could not find resource X" | Resource folder missing or misspelled | Check /home/server-data/resources/X/fxmanifest.lua exists |
| Players can't connect - "Connection timed out" | Port 30120 blocked by firewall | Run ufw allow 30120/tcp and ufw allow 30120/udp. Check your VPS provider's firewall too |
| Server dies when you close SSH | You didn't use screen | Always start the server inside screen -S fivem |
Permission denied when running run.sh | Script isn't executable | Run chmod +x /home/fxserver/run.sh |
apt: command not found | You're not on Ubuntu/Debian | This guide is for Ubuntu. For CentOS/RHEL, use yum instead of apt |