This is a complete install on a blank Debian or Ubuntu server, from a fresh SSH session to a FiveM server that survives a reboot. It takes about fifteen minutes of typing, and the only thing you have to leave the terminal for is the licence key.
The commands below are for Debian 11 or newer and Ubuntu 20.04 or newer. If you have not connected to the machine yet, start with Connecting to your server.
Before you start
You need three things: root access to the server, its public IPv4 address, and a Cfx.re account, which is the same account you use for the FiveM client. If you do not already have a database in mind, install one later; the base server does not need it.
The layout this guide builds:
/home/fivem/
├── artifacts/ the FXServer build: run.sh, alpine/
├── server-data/ resources/, server.cfg, your own scripts
└── txData/ created by txAdmin on first runKeeping the build and your data in separate directories is what makes an artifact update a folder swap rather than a merge. See Updating FiveM artifacts.
Install
Update the system and install the prerequisites
As root:
apt update && apt upgrade -y apt install -y curl xz-utils git tmux ca-certificatesxz-utilsunpacks the artifact archive,gitfetches the default server data, andtmuxis the fallback if you decide not to use systemd. The artifacts bring their own runtime, so there is no Node, .NET, or Mono to install.Create a user for the server
adduser --disabled-password --gecos "" fivemThat creates
/home/fivemwith no password login. Switch to it whenever you work on the server:su - fivemEverything in steps 3 to 7 runs as
fivem. The systemd unit in step 8 is written as root but runs the server asfivem.Fetch the artifacts
Open
https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/in a browser. Each row is a build, and one is marked as the recommended build. Copy its link, which ends infx.tar.xz.Then, as
fivem:mkdir -p ~/artifacts cd ~/artifacts curl -sSL -o fx.tar.xz "PASTE_THE_LINK_HERE" tar xf fx.tar.xz rm fx.tar.xz chmod +x run.shYou should now have
run.shand analpinedirectory. Take the recommended build rather than the newest one unless you have a specific reason; Updating FiveM artifacts covers the difference.Get the server data files
The artifacts contain the server, not a gamemode. Cfx.re publishes a starting set of resources:
git clone https://github.com/citizenfx/cfx-server-data.git ~/server-dataThat gives you
~/server-data/resources/with the default resources, and noserver.cfg. You write that yourself in step 6, or let txAdmin write one for you in step 7.Create a licence key in keymaster
Sign in at
https://keymaster.fivem.netwith your Cfx.re account and create a new server key. It asks for a label, so name it after this server, and for the server's IP address, which is the public IPv4 address of this machine.Copy the key somewhere safe. If the server later moves to a different address, edit the existing key in keymaster rather than creating a second one.
Open the ports
The server needs TCP and UDP 30120 reachable from the internet. On Clouduxe that is the Firewall tab: apply the FiveM (GTA RP) preset, which opens both in one step, or add the two rules yourself. See Game presets and Port rules.
If you have also enabled a firewall on the machine itself, open the ports there too. Check whether one is running:
ufw status nft list rulesetOn a stock Debian or Ubuntu image both usually come back empty, in which case there is nothing to do on the host.
Leave TCP 40120 closed to the internet. Step 7 reaches txAdmin over an SSH tunnel instead.
Start txAdmin and run the setup
From a fixed working directory, so txAdmin's
txDatafolder always lands in the same place:cd ~ ~/artifacts/run.shtxAdmin starts and prints a URL and a one-time PIN. The PIN expires after a few minutes; if you miss it, stop the process with Ctrl-C and start it again.
Rather than exposing port 40120, tunnel it over SSH. From your own computer, in a second terminal:
ssh -L 40120:127.0.0.1:40120 root@203.0.113.10Leave that running and open
http://127.0.0.1:40120in your browser. Enter the PIN, create your admin account with a strong password, then work through the setup: choose the option for an existing server data folder, give it/home/fivem/server-data, and paste the licence key from step 5. txAdmin writes aserver.cfgif there is not one already.Keep it running
The server should start on boot and restart if it crashes. As root, create
/etc/systemd/system/fivem.service:[Unit] Description=FiveM server (txAdmin) After=network-online.target Wants=network-online.target [Service] Type=simple User=fivem Group=fivem WorkingDirectory=/home/fivem ExecStart=/home/fivem/artifacts/run.sh Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.targetThen:
systemctl daemon-reload systemctl enable --now fivem systemctl status fivem journalctl -u fivem -fWorkingDirectorymatters. txAdmin keeps its own data beside the directory it is started from, so pinning it here means systemd and a manual run always find the same profile.Under this unit, systemd supervises txAdmin and txAdmin supervises the game server. Restarting from the txAdmin interface restarts the game server only;
systemctl restart fivemrestarts both.
Checking it worked
The console, in journalctl -u fivem -f or in txAdmin, tells you most of it.
Look for the line confirming licence key authentication, then for each resource
starting. A resource that fails to start says so on its own line, with the reason.
From another machine, confirm the TCP endpoint is reachable from outside:
curl -s http://203.0.113.10:30120/info.jsonA JSON reply means the port is open and the server is answering. A timeout means the port is closed somewhere between you and the server, and the server list is as stuck as you are. Nothing on the game port answers to a browser, so this is the honest test.
If that works and players still cannot join, work through When players cannot connect.
Running without txAdmin
You do not have to use txAdmin. Pass a config file and you get a plain server console instead:
cd ~/server-data
~/artifacts/run.sh +exec server.cfgIf you go this route, run it inside tmux so closing your SSH session does not
kill the server:
tmux new -s fivem
cd ~/server-data && ~/artifacts/run.sh +exec server.cfgDetach with Ctrl-b then d, and come back with tmux attach -t fivem. A tmux
session does not survive a reboot, so for anything you care about, use the
systemd unit and change its ExecStart to the command above.
Related
The keys to set once the server runs, and the two that are a security problem.
Updating FiveM artifactsUpdating the build you installed here, without losing the ability to roll back.
Console accessReaching the machine through the browser console when SSH is not available.
Running a FiveM serverThe pieces, the ports, and what each part is called.