[FX-Server] How to install FX Server on Centos 7

READ

Please note, you will need basic Linux experience for this. I’ll try to make this as “beginner” friendly as possible.

Prerequisites

Ensure you are logged in as root

You will need to run all of the following commands before we can start.

setenforce 0
yum update -y
yum install wget screen nano git -y

Preparing

Run all of the following commands. We are going prepare the directories for the server.
cd /home/
mkdir FiveM
cd FiveM

Getting the latest version of FiveM

Go to the artifacts link and find the artifact with the highest number and copy the url for the file “fx.tar.xf”

Installing FX Server

Now, we are actually downloading and running the server

Run the following commands

wget <url> 
Replace "<url>" with the link for the "fx.tar.xf" file

Now we have the server downloaded, now we need to extract it

cd /home/FiveM 
tar xf fx.tar.xz

Once you have it downloaded you will be able to see all of the server files and such. DO NOT RUN THE “run.sh” FILE!

Now we need to setup our “server-data” folder, this is where we will have the resources, and the server.cfg file for the server.

git clone https://github.com/citizenfx/cfx-server-data.git /home/FiveM/server-data
cd server-data

Now its time to make our server.cfg

nano server.cfg

Paste this into the your ssh client (If you are using Putty just right click)

# 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 sessionmanager
start fivem
start hardcap
start ■■■■■■■
start scoreboard
start playernames

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

# remove the # to hide player endpoints in external log output
#sv_endpointprivacy true

# server slots limit (must be between 1 and 31)
sv_maxclients 30

# license key for server (https://keymaster.fivem.net)
sv_licenseKey changeme

Change the config how you want then once you are done press “CTRL + X” then “Y” then “Enter”.

Now we need to finish up a couple little things before we can start the server.

Centos 7 comes default with firewalld so use the following commands to open the ports for the server

firewall-cmd --add-port 30120/tcp
firewall-cmd --add-port 30120/tcp --permanent
firewall-cmd --add-port 30120/udp 
firewall-cmd --add-port 30120/udp --permanent
firewall-cmd --reload

If you get command not found, run these commands, followed by the ones above.

yum install firewalld -y
systemctl start firewalld
systemctl enable firewalld

This will open up the port “30120” for TCP and UDP.

Now we can run our server. Go into your “server-data” folder (by using cd /home/FiveM/server-data)
Then run this:

bash /home/FiveM/run.sh +exec server.cfg

How to use Screen

To start your server:

screen -dmS FiveM bash /home/FiveM/run.sh +exec server.cfg

The command above will start your server, but not attach you to the screen (meaning you won’t see the output).

To attach to the screen:

screen -x FiveM

To resume the screen:

screen -r FiveM

What's the difference between attach and resume?

Attaching to the screen with `-x` will allow multiple people to be in the screen at the same time (good if multiple people want to be in the screen at the same time).

Resuming the screen basically makes you the primary user in the screen, any other users who want to join the screen, must use -x.

How to install MySQL

Note this is MariaDB, but will work the exact same as MySql

MariaDB is a fork of MySql (meaning all MySql applications will work the same on MariaDB).

yum install mariadb-server -y

systemctl start mariadb
systemctl enable mariadb

mysql_secure_installation

Recommended settings (during the mysql_secure_installation):
disallow root login remotely
remove test databases, and access to them.
remove test users
reload privilege table

I hope you understood most of this, if you have any questions let me know.

5 Likes

Excellent guide, thank you so much for taking the time to write it. One thing that should be corrected:

tar xf fx.tar.xf should be tar xf fx.tar.xz

Thanks. It’s been corrected.

great tut you should add installing the mysql server also

I don’t mind adding that, I’ll start on it soon.

1 Like

thank you so much man, you solved a lot of problems for me !

Where am find Resource to add Scripts ??

Hi my server is not showing on fivem server list i tried updating artifacts etc even license key
and still nothing

I’v got a problem that the installing stop at WebServer. It shows in the pictrue. Please give a help. Thank you!

One thing to note. You install “screen” right at the top but do not show usage later on in the HowTo, why?

Starting the Server on CentOs the way described forces you to leave the console session open, that is fine for testing but not for runing 24x7.

Any template for a systemd file using screen, as I did not find a way to start it sensibly with nohub as there is no way of getting onto the cfx console?

Setting up systemd services is not difficult, there are plenty of tutorials. The commands for screen, I’ll include it in the post, but also here:

screen -dmS FiveM <run script>

# View the screen
screen -x FiveM (attach, allows for multiple ssh connections to be in the same screen)

or

screen -r FiveM (to resume)

# To forcefully kill the screen (not recommended, join the screen and press CTRL +C)
screen -X -S FiveM kill

Happy server running.