← Blog

How to Create a FiveM Server From Scratch?

Par Benjamin D. · PDG

· Mis à jour le August 14, 2026 · Lecture 11 min

Contents

Setting up a FiveM server in 2026 is far easier than it was a few years ago, but the details still make the difference between a roleplay city that runs at a stable 60 FPS and one that stutters every time a player spawns a vehicle. This tutorial walks through the full process: hardware choices, artifacts, server.cfg, txAdmin, database, resources, and security hardening.



What you need before creating a FiveM server

A FiveM server is a dedicated GTA V multiplayer runtime (FXServer) that loads your own resources: scripts, maps, vehicles, ESX or QBCore frameworks, and a MySQL/MariaDB database for persistence. Unlike a vanilla Minecraft server, most of the CPU cost comes from Lua/JS script execution and database queries, not from world generation.

The three prerequisites

  • A legitimate GTA V copy for every player who connects (Steam, Rockstar Games Launcher, Epic). The server itself does not need the game files.
  • A Cfx.re account and a server license key, generated for free from the official Cfx.re keymaster portal. One key per server instance.
  • Hosting with real CPU headroom. FXServer is heavily single-thread dependent: the main thread executes the resource tick loop. High clock speed matters far more than core count.

Sizing your machine realistically

People routinely overestimate RAM needs and underestimate CPU frequency needs. A rough field guide:

Server typePlayersRecommended profileNotes
Test / dev instance1–82 vCPU high-frequency, 4 GB RAM, NVMeVanilla + a few resources
Small RP (ESX/QBCore light)16–324 vCPU Ryzen, 6–8 GB RAMMySQL on the same host is fine
Full RP city48–644–6 vCPU Ryzen, 12–16 GB RAM200+ resources, heavy MySQL usage
Large city, many jobs/scripts64–1286–8 vCPU Ryzen, 16–32 GB RAMOptimised scripts mandatory

Two hardware criteria are non-negotiable for a FiveM server: high-frequency Ryzen CPU (script ticks are latency-sensitive) and NVMe SSD storage (streaming assets and MySQL reads). Classic SATA storage shows up immediately as texture pop-in and slow queries once you pass a few dozen concurrent players. This is exactly why our Serveur FiveM offers run on Ryzen + NVMe with anti-DDoS enabled by default — GTA RP communities are a very frequent target for volumetric attacks.



Method 1: deploy a FiveM server from a game panel (fastest)

If you want your server online in minutes and you'd rather spend your time on scripts than on Linux administration, use a managed game hosting instance with a Pterodactyl panel. The FXServer egg handles artifact download, updates and startup parameters for you.

Step-by-step

  1. Order the instance and pick the FiveM game type. Installation is instant — the panel pulls the latest recommended FXServer build.
  2. Get your license key from the Cfx.re keymaster and paste it into the sv_licenseKey field (either in the panel startup variables or in server.cfg).
  3. Open the File Manager and locate server.cfg plus the resources/ folder.
  4. Upload your resources. For large packs (vehicle streams, MLOs), zip locally, upload the archive, then extract server-side — far faster than uploading thousands of small files.
  5. Start the server from the live console and watch the boot log for red lines.
  6. Connect from the FiveM client with connect your.ip:30120 in the F8 console.

A working server.cfg baseline

# ---- Network endpoints ----
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

# ---- Core resources ----
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
ensure basic-gamemode
ensure hardcap
ensure rconlog

# ---- Database (oxmysql / mysql-async) ----
set mysql_connection_string "mysql://fivem:[email protected]/fivem_rp?charset=utf8mb4"

# ---- Framework ----
# ensure oxmysql
# ensure es_extended
# ensure qb-core

# ---- Server identity ----
sv_hostname "^2[EU] My RP City ^7| ESX | Whitelist"
sets sv_projectName "My RP City"
sets sv_projectDesc "Serious roleplay, active staff"
sets tags "roleplay, esx, economy, whitelist"
sets locale "en-US"
load_server_icon myicon.png

# ---- Slots & OneSync ----
sv_maxclients 64
set onesync on
set onesync_population true

# ---- Security ----
sv_scriptHookAllowed 0
rcon_password "USE_A_LONG_RANDOM_STRING"
sv_authMaxVariance 1
sv_authMinTrust 5

# ---- Steam / license ----
set steam_webApiKey "YOUR_STEAM_WEB_API_KEY"
sv_licenseKey "YOUR_CFX_LICENSE_KEY"

# ---- Admins ----
add_ace group.admin command allow
add_ace group.admin command.quit deny
add_principal identifier.fivem:1234567 group.admin

Two lines deserve attention. sv_scriptHookAllowed 0 blocks single-player script hooks — leaving it at 1 on a roleplay server is an open door to trainers. And onesync on is mandatory above 32 slots; it also changes how entities are handled, so test your scripts after enabling it.

Panel features you'll actually use daily

  • Live console: read Lua errors in real time, run refresh, ensure resource_name, stop/start without a full restart.
  • Scheduled restarts: a nightly restart clears memory leaks from badly written resources.
  • Automatic backups: your resources/ folder and SQL dumps are the two things you can never afford to lose.
  • Sub-users: give a developer console + file access without handing over billing or the ability to reinstall the server.


Method 2: install a FiveM server manually on a Linux VPS

Self-hosting on a VPS Linux gives you full control: your own MySQL tuning, multiple FXServer instances, custom txAdmin setup, a web panel, a Discord bot, all on the same machine. Below is a clean Debian/Ubuntu install.

1. Prepare the system

# Connect as root, then create a non-root user
ssh root@YOUR_SERVER_IP
adduser fivem
usermod -aG sudo fivem

apt update && apt upgrade -y
apt install -y curl wget git xz-utils screen unzip mariadb-server ufw fail2ban

2. Secure SSH access with keys

Do this before anything else. Generate a key pair on your own workstation:

ssh-keygen -t ed25519 -C "fivem-admin"
ssh-copy-id fivem@YOUR_SERVER_IP

Then disable password login and root login:

sudo nano /etc/ssh/sshd_config
# PermitRootLogin no
# PasswordAuthentication no
# PubkeyAuthentication yes

sudo systemctl restart ssh
sudo systemctl enable --now fail2ban

3. Firewall rules

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp
sudo ufw allow 40120/tcp     # txAdmin web interface
sudo ufw enable
sudo ufw status verbose

Note that MySQL port 3306 is not opened. Keep the database bound to 127.0.0.1 and let FXServer reach it locally. Volumetric DDoS filtering is handled upstream at the network level on Fly-Serv infrastructure, so your job here is limited to host-level hygiene: closed ports, key-based SSH, and strong credentials.

4. Create the database

sudo mysql_secure_installation

sudo mysql -u root -p
CREATE DATABASE fivem_rp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'fivem'@'localhost' IDENTIFIED BY 'A_LONG_RANDOM_PASSWORD';
GRANT ALL PRIVILEGES ON fivem_rp.* TO 'fivem'@'localhost';
FLUSH PRIVILEGES;
EXIT;

5. Download FXServer artifacts

su - fivem
mkdir -p ~/fxserver/server ~/fxserver/server-data
cd ~/fxserver/server

# Replace with the current recommended Linux build URL from the artifacts page
wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/XXXX-HASH/fx.tar.xz
tar xf fx.tar.xz && rm fx.tar.xz

# Base server data (cfx-server-data)
git clone https://github.com/citizenfx/cfx-server-data.git ~/fxserver/server-data

Always take a recommended build rather than the newest optional one: bleeding-edge artifacts occasionally break natives your resources depend on. Full details and current download links live in the Source official documentation.

6. First launch with txAdmin

cd ~/fxserver/server-data
bash ~/fxserver/server/run.sh

On first boot, txAdmin prints a one-time PIN and a URL like http://YOUR_IP:40120. Open it, create your admin account, then use the setup wizard to point txAdmin at your server-data folder and your MySQL credentials. txAdmin gives you player management, bans, scheduled restarts, live resource control and log viewing — treat it as your operational cockpit.

7. Run it as a systemd service

Don't leave FXServer inside a detached screen you'll forget about. A unit file gives you auto-restart on crash and boot persistence:

sudo nano /etc/systemd/system/fivem.service
[Unit]
Description=FiveM FXServer
After=network.target mariadb.service

[Service]
Type=simple
User=fivem
WorkingDirectory=/home/fivem/fxserver/server-data
ExecStart=/bin/bash /home/fivem/fxserver/server/run.sh
Restart=always
RestartSec=10
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now fivem
sudo systemctl status fivem
journalctl -u fivem -f

If you'd rather manage several instances through a graphical panel while keeping root access, a VPS Pterodactyl is the middle ground: Docker-isolated servers, per-instance resource limits, and the same file manager and console you'd get from a managed offer. Windows-centric admins who script in PowerShell or use graphical MySQL tools can equally run FXServer on a VPS Windows.



Optimising and securing your FiveM server for production

Getting the server online is 20% of the work. Keeping a 64-player city smooth is where administration really begins.

Diagnose before you buy more hardware

FiveM ships with the tools you need. In the client F8 console:

resmon 1          # per-resource CPU time and memory
netgraph 1        # packet loss, latency, in/out rate
profiler record 500
profiler view

Interpretation rules from the field:

  • Any resource consistently above 0.5 ms in resmon deserves a look.
  • Above 2 ms on a single resource, you have a real problem — usually an unthrottled Citizen.CreateThread loop with Wait(0).
  • Server-side, watch the console for hitch warning messages. Repeated hitches mean the main thread is blocked, often by synchronous MySQL calls.

Common performance killers

SymptomLikely causeFix
Client FPS drops in crowded areasToo many streamed props/MLOs, unoptimised YMAPsReduce LODs, split streaming into multiple resources, remove duplicate props
Server hitch warnings every few secondsBlocking database queries, heavy loopsSwitch to oxmysql async queries, add indexes on identifier columns
Rubber-banding, desyncOneSync misconfiguration or network saturationVerify onesync on, check netgraph packet loss, review entity spawn volume
Very long boot timeHundreds of resources loading sequentially from slow diskNVMe storage, prune unused resources
Memory grows until crashLeaking resourceNightly scheduled restart via txAdmin + isolate with resmon memory column

Security checklist

  • Never publish your RCON password and never reuse it. If you don't use RCON at all, leave it unset rather than weak.
  • Whitelist — either via txAdmin's built-in whitelist, a Discord role check, or your framework's system. It removes 90% of trolling and cheat-testing traffic.
  • Use ACE permissions properly. Grant commands to groups, add principals by identifier, and explicitly deny dangerous commands like quit.
  • Audit downloaded scripts. Escrowed or obfuscated resources from unknown sources are the single most common backdoor vector on RP servers. Search for suspicious PerformHttpRequest calls to unknown domains.
  • Set sv_authMinTrust to filter accounts with poor Cfx trust scores.
  • Back up both halves. Your resources/ folder and a MySQL dump. A resource backup without the database is worthless on a roleplay server.
# Simple nightly database dump (cron)
0 4 * * * /usr/bin/mysqldump -u fivem -p'PASSWORD' fivem_rp | gzip > /home/fivem/backups/fivem_rp_$(date +\%F).sql.gz

On managed instances, automatic backups already cover the server files; adding a scheduled SQL dump gives you full coverage. Keep at least seven daily rotations — schema-breaking script updates are usually discovered a day or two later.

Keeping artifacts up to date

Update FXServer roughly once a month, and always after a major GTA V game patch. Procedure: stop the server, back up server-data, replace the artifact folder, restart, then read the console for deprecated native warnings. On a panel, this is often a single startup-variable change followed by a reinstall of the server binary — your resources/ and configs stay untouched.

Growing the community

Once the technical side is stable, the differentiators become latency and uptime. Host in the region where most of your players live — a French or Western European location for an EU-focused RP city keeps ping under 30 ms for the majority. Publish your restart schedule, and keep a test instance so you never push an untested script to your live FiveM server. If you also run other communities, the same panel logic applies to a Serveur Minecraft or a Serveur Rust, and you can browse Tous nos serveurs de jeu for the full list of supported games. More tutorials are available on the Blog Fly-Serv.



Conclusion

Deploying a FiveM server comes down to three things: a high-frequency CPU with NVMe storage, a clean server.cfg with OneSync and script hooks disabled, and disciplined maintenance through txAdmin or your panel. Start small, profile with resmon, add resources one at a time, and back up the database alongside your files. That workflow scales from a 16-slot test city to a full 128-slot roleplay server.



FAQ

How much RAM and CPU does a 64-slot FiveM roleplay server really need?

Plan for 4 to 6 high-frequency Ryzen vCPU and 12–16 GB of RAM with NVMe storage for a full ESX or QBCore city at 64 slots. CPU clock speed matters more than core count because FXServer's main tick loop is single-threaded. If you see hitch warnings, profile with resmon and profiler record first — badly written scripts cause more lag than insufficient hardware in most cases.

Do I need OneSync, and what changes when I enable it?

Yes, above 32 slots OneSync is mandatory. Add set onesync on and set onesync_population true to server.cfg. It moves entity ownership handling server-side, which improves sync but breaks older client-side scripts that assume local entity control. Test every resource after enabling it, especially vehicle, NPC and inventory scripts, and update anything still using deprecated legacy natives.

What's the difference between a managed FiveM instance and installing it myself on a VPS?

A managed instance gives you instant installation, a ready-made Pterodactyl panel, automatic backups and artifact updates handled for you — ideal if you want to focus on scripts. A VPS gives root access: multiple FXServer instances, your own MySQL tuning, custom systemd services and extra tools like Discord bots. Choose the VPS route only if you're comfortable with SSH keys, ufw and fail2ban.