[FX-Server][Tutorial] How To Setup FX-Server On Linux - From Start To Finish

FX-Server is finally here! Stability updates, increased playercaps, more natives, features, and so much more stuff that still needs to be documented haha! The future is now!

Hello, this is an in-depth and “Noob Friendly” guide on how to install FiveM’s latest FX-Server on a completely fresh Linux installation.

I’m going to assume you know how to SSH / FTP into your server for the entirety of this tutorial.

Please read each step carefully before asking for troubleshooting help <3


Requirements:

  • Obtain Root access on your server

  • Update / Upgrade to ensure you are all up-to-date

apt-get update && apt-get upgrade

Step 1) Setting Up Your FiveM Server!

Alright, follow along exactly. We’re going to try to stay in the same directory so that there is no confusion. Lets start with:

cd ~

That’ll take you to your root directory. Next, lets navigate to the place where we’re going to install the server.

The home directory where the server will be stored.

cd /home/

Navigate here and copy the URL to the latest version of FiveM Linux Server.

Next you’ll want to download the latest version of FiveM Server from that link using wget -url- command:

wget https://example.com/file.zip

Obviously change the URL to the one you found in the repo above.


We’re gonna want to make this all neat and stuff, so lets create a directory to store the server:

mkdir fx-server

then

mkdir fx-server-data

Alright, so next we’re gonna unpack this file. Do so by typing the following:

tar -xvf fx.tar.xz -C /home/fx-server/

And that’ll unpack the FX-Server binaries for you, next we need to grab the resources and whatnot. Lets navigate back to our main folder.

cd /home/

You can grab the resources by typing the following:

git clone https://github.com/citizenfx/cfx-server-data.git fx-server-data

You’re nearly finished. Lets get into that cfx-server-data folder by typing:

cd fx-server-data

and now we need to create our very own server.cfg. Do so by typing:

nano

Next, you’ll want to copy this big chunk of text and paste it into the SSH client. (You can do so by right clicking anywhere inside the screen)

# you probably don't want to change these!
# only change them if you're using a server with multiple network interfaces
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

start mapmanager
start chat
start spawnmanager
start fivem
start hardcap
start ■■■■■■■

sv_scriptHookAllowed 1

# change this
#rcon_password yay

sv_hostname "My new FXServer!"

# nested configs!
#exec server_internal.cfg

# loading a server icon (96x96 PNG file)
#load_server_icon myLogo.png

# convars for use from script
set temp_convar "hey world!"

# disable announcing? clear out the master by uncommenting this
#sv_master1 ""

# want to only allow players authenticated with a third-party provider like Steam?
#sv_authMaxVariance 1
#sv_authMinTrust 5

# 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:110000112345678 group.admin # add the admin to the group

# player endpoint protection
sv_endpointprivacy true

After you grab that large chunk of text you’ll want to press the keys

CTRL + O

Which will write-out of the file, and will prompt you to enter a name. You NEED to name this file:

server.cfg

Follow up by pressing Enter and using the command:

CTRL + X

To exit the file.

Congratulations FX-Server is technically setup. I wont be going over how all the server.cfg variables work, that information should, at some point, be available here: LINK


Step 2) Adding Resources / Mods

Alright, so you want to add mods to your server, right? You have two options. You can manually develop them on Linux, which is a pain in the arse, or you can develop them on a local fx-server, which is definitely the ideal approach. I’m going to show you how I update resources after I’ve finished testing them on my local machine.

Lets open up Filezilla and connect to our server. I am not going to be teaching how to FTP into servers, but you should navigate to your local resource you want to copy over, and the /home/fx-server-data/resources/ folder like such:

Just drag and drop them in, and be sure to add them to your server.cfg by adding

start resourcename

Here’s a test resource for you to try yourself. It’s a simple ragdoll script for when you Press X.

ragdoll.7z (536 Bytes)

Be sure to add

start ragdoll

to your server.cfg :slight_smile:

Step 3) Updating your certs!

Luckily this last step is super simple, but very important. If you get a TrustFailure issue when you try to join your server, it’s because you did not follow this step!

You’ll want to type:

sudo cert-sync /etc/ssl/certs/ca-certificates.crt

Followed by,

apt-get update && apt-get upgrade

Step 4) Running Your Server!

You can now start your server by navigating to your cfx-server folder:

cd /home/fx-server-data/

and typing:

bash /home/fx-server/run.sh +exec server.cfg

You can also close the server by pressing the command:

CTRL + C

You’ll notice at this point you need to leave your SSH session open to keep the server active. You can fix that by following Step 4.5 which is optional but in my opinion extremely important.

Step 4.5 (Optional)

Alternatively, you can run your server in a… virtual SSH session, which will allow you to drop out of the main session without the server automatically closing. You can do so by typing:

screen

This will prompt you to press your SPACE key a few times, but in general when you get into the new “Screen”, everything will look relatively familiar. The difference is this is a virtual screen.

You can again, in this session, navigate to your server folder and run the server from here. The difference being when you leave it will remain running. To exit this session, you can simply press the command:

CTRL + A + D

And to rejoin the session when you’re back at the main terminal you can press the command:

screen -r

Conclusion

That should be it! You are now the proud owner of a fresh and functioning FiveM server running the latest and greatest FX-Server! If you have any questions, concerns, or issues, let me know in the comments and I will eventually get back to you! I hope you enjoy FX-Server and enjoy all the new features that come with it!

Credits and reference goes to:

And anyone / anything else I may have missed!

Thank you for getting this far. Have a great day!

33 Likes

Thanks dude !

Yesterday I tested 3 times the wiki tuto with failing, but with both tuto it’s great !

Link your tuto to wiki if you can :wink:

And big up to FiveM :mascot:

2 Likes

Haha, I’ll be contributing to the wiki starting when I have more time. I’m glad I was able to help! Enjoy!

2 Likes

Very nice tutorial, I’m getting a linux vps soon, so I can’t wait to try this out.

2 Likes

If anyone was struggling with step 4 (running) it was because I forgot to set the bash command to the correct directory. Assuming you followed along it’s fixed now.

Do i have to run as root or can i make a custom user for fx-server?

You mean run the server as root? The bash script?

You should be able to do that assuming you give the user all perms.

Do you have some informations to tell us about logging files ?

It looks like that the new fxserver doesn’t use nLog, so I’m asking myself how to get error log for LUA developpers

Unfortunately I wouldn’t know. I just use Citizen.Trace(“debug code”) and print(“debug code”) to debug my lua scripts.

Client scripts print to F8,
Server scripts print to server console.

1 Like

It says that the file does not exist, you probably didn’t use wget command to download the archive.
Do:

cd /home/

Type / Paste:

wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/287-c382fc131361bff1c5cee6a6745020808a350c95/

Then try that tar command <3

I realised that you need to click on the version and then copy whats inside than copying the link of the version

What worked for me was: https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/287-c382fc131361bff1c5cee6a6745020808a350c95/fx.tar.xz

Haha no worries, I can understand the confusion. I unfortunately cannot include a link in the main post as it will quickly become out-dated :slight_smile:

do you have to manually update your server every time a new update comes? If so how would I go on about doing that while retaining my server details

Ironically that’s something I looked into just after I posted this. Yes, you should be able to update the server as new updates come out (Which is why you separate your resources from your server software in this tutorial ^^)

I would assume all you have to do is download the latest tarball file (From the repo you were just in) and extract it into the other folder. Shouldn’t be too complicated to just delete / replace the old one. I’d probably just rename the old fx-server folder into fx-server-temp (for backup) and then repeat the steps to download the latest / unpack into fx-server.

I wouldn’t worry about it for now. Just keep updating it every few days / weeks.

1 Like

Once again, thanks for the sharing

So I got everything configured and the log looks good (I think) after startup:

#/fx-server/run.sh +exec server.cfg
Initializing Mono
Initializing Mono completed
Hello!
Failed to get instance for guid a7242855-0350-4cb5-a0fe-61021e7eafaa and iid 567634c6-3bdd-4d0e-af39-7472aed479b7: System.InvalidOperationException: Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00011] in <fb8f7831037a4d3481e7bbe63117e3d0>:0
  at CitizenFX.Core.RuntimeManager.CreateObjectInstance (System.Guid guid, System.Guid iid) [0x00014] in /src/code/client/clrcore/RuntimeManager.cs:39
Found new resource fivem-awesome1501 in /servers/gtarp/fx-server-data/resources//fivem-awesome1501
Found new resource ragdoll in /servers/gtarp/fx-server-data/resources//ragdoll
Found new resource fivem-map-skater in /servers/gtarp/fx-server-data/resources//fivem-map-skater
Found new resource fivem in /servers/gtarp/fx-server-data/resources//fivem
Found new resource fivem-map-hipster in /servers/gtarp/fx-server-data/resources//fivem-map-hipster
Found new resource obituary in /servers/gtarp/fx-server-data/resources//[gameplay]/obituary
Found new resource channelfeed in /servers/gtarp/fx-server-data/resources//[gameplay]/channelfeed
Found new resource obituary-deaths in /servers/gtarp/fx-server-data/resources//[gameplay]/obituary-deaths
Found new resource irc in /servers/gtarp/fx-server-data/resources//[gameplay]/irc
Found new resource mapmanager in /servers/gtarp/fx-server-data/resources//[managers]/mapmanager
Found new resource scoreboard in /servers/gtarp/fx-server-data/resources//[system]/scoreboard
Found new resource chat in /servers/gtarp/fx-server-data/resources//[system]/chat
Found new resource baseevents in /servers/gtarp/fx-server-data/resources//[system]/baseevents
Found new resource sessionmanager in /servers/gtarp/fx-server-data/resources//[system]/sessionmanager
Found new resource ■■■■■■■ in /servers/gtarp/fx-server-data/resources//[system]/■■■■■■■
Found new resource spawnmanager in /servers/gtarp/fx-server-data/resources//[system]/spawnmanager
Found new resource hardcap in /servers/gtarp/fx-server-data/resources//[system]/hardcap
Found new resource keks in /servers/gtarp/fx-server-data/resources//[test]/keks
Found new resource gameInit in /servers/gtarp/fx-server-data/resources//[test]/gameInit
Found new resource betaguns in /servers/gtarp/fx-server-data/resources//[test]/betaguns
Found new resource race-test in /servers/gtarp/fx-server-data/resources//[gamemodes]/race-test
Found new resource race in /servers/gtarp/fx-server-data/resources//[gamemodes]/race
Started resource sessionmanager
Started resource mapmanager
Started resource chat
Started resource spawnmanager
Started resource fivem
Started gametype Freeroam
Started resource hardcap
Started resource ■■■■■■■
Started resource ragdoll
Resolved live-internal.fivem.net:30110 to 151.80.44.223:30110
Sending heartbeat to live-internal.fivem.net:30110
Started resource fivem-map-hipster
Started map fivem-map-hipster

The ports are forwarded (not that it matters, because) I cannot connect, even over LAN, using the local IP of the server…

Imgur

So what the hell could be the problem? I ran an lsof and everything seems to be listening, and the port is open on the firewall. I have plenty of other servers running just fine from this hardware and network setup.

#lsof -i -P -n | grep FXServer
FXServer  23116     root   11u  IPv4 8371930      0t0  TCP *:30120 (LISTEN)
FXServer  23116     root   12u  IPv6 8371931      0t0  UDP *:30120

Firewall:

#ufw status
Status: active

To                         Action      From
--                         ------      ----
30120                      ALLOW       Anywhere
30120 (v6)                 ALLOW       Anywhere (v6)
1 Like

I second this, I can’t get it to work for me on Ubuntu Server 16.04, It looks like it’s running but I can’t even curl 127.0.0.1:30120/info.json on the save machine.

1 Like

DeeJayh, Based on your logs it looks like the server is setup and running properly. It’s likely problem with your ports. Can you check to see if port:30120 is open using www.canyouseeme.org?

Same goes for you Timmy. Thanks.

Like I said it looks like everything is setup correctly the only other possible issue is your ports. the GUID error is just something FX-Server does. Not quite sure why.

Also please ensure you followed all the steps in the correct order. If the issue persists consider reformatting your VPS and trying again from scratch as this tutorial assumes there are no conflicting applications.

Also your specific log references: Resolved live-internal.fivem.net:30110 to 151.80.44.223:30110

Have you edited your server.cfg? Make sure the endpoints are 0.0.0.0 like:

endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

Obviously I wasn’t clear. This isn’t a VPS, it’s a personal server. It’s on my private, local network. My gaming rig is connected to the same network. I can’t access it even from my gaming rig on the same subnet. All other services work fine, from other game servers, to discord bots, and more. So let’s break it down:

  • The server is outside of the network firewall, fully exposed to the internet, protected only by it’s own firewall. It’s called De-Militarized Zone (DMZ) and so it does not require port forwarding. (All other services hosted work fine, and there’s quite a few of them, none of which are port forwarded)
  • I showed you the log, you said it looks right.
  • I showed you the port is open to any traffic from any interface (port 30120) from the firewall
  • I showed you the lsof that proves the service is listening on the correct port on any interface (*:30120)
  • I also cannot cURL the info.json, from the server, using curl 127.0.0.1:30120/info.json

Here is my server config with some info redacted:

# you probably don't want to change these!
# only change them if you're using a server with multiple network interfaces
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

start mapmanager
start chat
start spawnmanager
start fivem
start hardcap
start ■■■■■■■

sv_scriptHookAllowed 1

# change this
rcon_password redacted

sv_hostname "Redacted"

# nested configs!
#exec server_internal.cfg

# loading a server icon (96x96 PNG file)
load_server_icon redacted.png

# convars for use from script
set temp_convar "hey world!"

# disable announcing? clear out the master by uncommenting this
#sv_master1 ""

# want to only allow players authenticated with a third-party provider like Steam?
sv_authMaxVariance 1
sv_authMinTrust 5

# 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:0000000000000000 group.admin # add the admin to the group

# player endpoint protection
sv_endpointprivacy true

I’m stumped.

Here is a little tip for sessionmanager restarting issue on Linux (expecting you have same directories than tutorial)

Add Icecon bin to /home/icecon and set execute right (chmod +x)

Then edit /home/fx-server/run.sh and add the sleep line like this :

#!/bin/bash

# save the script directory
# from https://stackoverflow.com/a/4774063/223967
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd`
popd > /dev/null

# run proot
exec $SCRIPTPATH/proot -b $PWD -R $SCRIPTPATH/alpine/ /opt/cfx-server/FXServer +set citizen_dir /opt/cfx-server/citizen/ $*

sleep 20 /home/icecon/icecon_linux_amd64 localhost:30120 rcon_password --command "restart sessionmanager"

At server launch, after 20sec, this will automatically do the restart sessionmanager needed with rcon to fix the issue

1 Like