Open the official website, click to download the server (non-commercial) , as shown in the figure
Web page jumps to the official documentation
This instruction document provides installation methods on Windows and Linux, which are introduced one by one below.
Windows
prerequisites:
1.Visual C++ Redistributable 2019
2.Git
3. One high configuration server
installation steps
1. Create a new folder as D:\FxServer
2. Download the latest Windows server file: artifacts server
3. Unzip the downloaded server file into FxServer
a folder
4. Clone cfx-server-data D:\FxServer
to , and rename it server-data
to server
the same level . Command:git clone https://github.com/citizenfx/cfx-server-data.git server-data
5. server-data
Create a configuration file under the folder server.cfg
. The content of the file comes from example server.cfg, and the content is as follows:
# Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only.
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
# These resources will start by default.
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
ensure fivem
ensure hardcap
ensure rconlog
ensure scoreboard
# This allows players to use scripthook-based plugins such as the legacy Lambda Menu.
# Set this to 1 to allow scripthook. Do note that this does _not_ guarantee players won't be able to use external plugins.
sv_scriptHookAllowed 0
# Uncomment this and set a password to enable RCON. Make sure to change the password - it should look like rcon_password "YOURPASSWORD"
#rcon_password ""
# A comma-separated list of tags for your server.
# For example:
# - sets tags "drifting, cars, racing"
# Or:
# - sets tags "roleplay, military, tanks"
sets tags "default"
# A valid locale identifier for your server's primary language.
# For example "en-US", "fr-CA", "nl-NL", "de-DE", "en-GB", "pt-BR"
sets locale "root-AQ"
# please DO replace root-AQ on the line ABOVE with a real language! :)
# Set an optional server info and connecting banner image url.
# Size doesn't matter, any banner sized image will be fine.
#sets banner_detail "https://url.to/image.png"
#sets banner_connecting "https://url.to/image.png"
# Set your server's hostname
sv_hostname "FXServer, but unconfigured"
# Nested configs!
#exec server_internal.cfg
# Loading a server icon (96x96 PNG file)
#load_server_icon myLogo.png
# convars which can be used in scripts
set temp_convar "hey world!"
# Uncomment this line if you do not want your server to be listed in the server browser.
# Do not edit it if you *do* want your server listed.
#sv_master1 ""
# 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.fivem:1 group.admin # add the admin to the group
# Hide player endpoints in external log output.
sv_endpointprivacy true
# Server player slot limit (must be between 1 and 32, unless using OneSync)
sv_maxclients 32
# Steam Web API key, if you want to use Steam authentication (https://steamcommunity.com/dev/apikey)
# -> replace "" with the key
set steam_webApiKey ""
# License key for your server (https://keymaster.fivem.net)
sv_licenseKey changeme
Chinese explanation:
# 一般情况下不用修改!
# 只有使用多个服务器协议的时候才需要更改。默认的TCP和UDP端口为30120
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 rconlog
start scoreboard
start playernames
# 允许玩家使用scripthook挂载的修改器,例如lambda菜单。
# 设置为0可以禁用。
sv_scriptHookAllowed 1
# 取消前面的#可以启动RCON,记住你更改的密码。
#rcon_password changeme #一般用不到
# 服务器标签,中间用逗号隔开
# 例如:
# - sets tags "drifting, cars, racing"
# 或者:
# - sets tags "roleplay, military, tanks"
sets tags "default"
# 设置服务器横幅或者链接横幅的URL
# 大小没有限制,任何图像都可以.
#sets banner_detail "http://url.to/image.png"
#sets banner_connecting "http://url.to/image.png"
# 设置服务器名称
sv_hostname "My new FXServer!"
# 嵌套配置!一般不改。
#exec server_internal.cfg
# 服务器LOGO图标 (96x96 PNG文件)
#load_server_icon myLogo.png
# 可以在脚本中使用的封面。
set temp_convar "hey world!"
# #如果你不想服务器显示在FiveM网页服务器列表,可以把#号删掉。
#sv_master1 ""
# 只能让Steam或者第三方运营商进入你的FiveM服务器?
# 不要忘记Social Club也是第三方提供商!
# 一般不改
#sv_authMaxVariance 1
#sv_authMinTrust 5
# 添加系统管理员。
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:1 group.admin # add the admin to the group
# 在外部输出日志上不显示玩家的信息。
sv_endpointprivacy true
# 服务器人数设置 (必须在 1 到 32)
sv_maxclients 32
# 服务器密钥 (https://keymaster.fivem.net)
sv_licenseKey changeme
A few items that need to be modified are:
sv_hostname : server name, write casually
load_server_icon : icon displayed in the server list, remove # to indicate open, the custom picture must be a png picture with 96x96 resolution and put it in the add_principalserver-data
directory
same level as the configuration file identifier.steam : add an administrator according to the registered account ID
6. Go to the FiveM forum to register an account
7. Get the server key again (there is no limit to the number of serial number applications)
8. After applying for the serial number, replace server.cfg
the last part of the configuration file changeme
with the serial number applied in the previous step
9. Open the terminal and enter the following two commands to start the server:
cd /d D:\FXServer\server-data
D:\FXServer\server\run.cmd +exec server.cfg
Note: If you find it troublesome to start the server every time, you can create a new bat file, paste the above two commands into it, and double-click the bat file every time you start the server
Linux
Since the building method of Linux is similar to that of Windows, an automated deployment script has been compiled
#下载服务器文件
wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/1688-c814f804e64c28952269bc5abbac92d7c956f844/fx.tar.xz
#下载资源文件
git clone https://github.com/citizenfx/cfx-server-data.git server-data
#创建文件夹
mkdir -p /usr/local/src/FiveM/server
#解压服务器文件到指定文件夹
tar -xf fx.tar.xz -C /usr/local/src/FiveM/server
#复制资源文件到指定文件夹
cp -r server-data /usr/local/src/FiveM/
#创建配置文件
cat <<EOF >/usr/local/src/FiveM/server-data/server.cfg
# Only change the IP if you're using a server with multiple network interfaces, otherwise change the port only.
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
# These resources will start by default.
ensure mapmanager
ensure chat
ensure spawnmanager
ensure sessionmanager
ensure fivem
ensure hardcap
ensure rconlog
ensure scoreboard
# This allows players to use scripthook-based plugins such as the legacy Lambda Menu.
# Set this to 1 to allow scripthook. Do note that this does _not_ guarantee players won't be able to use external plugins.
sv_scriptHookAllowed 0
# Uncomment this and set a password to enable RCON. Make sure to change the password - it should look like rcon_password "YOURPASSWORD"
#rcon_password ""
# A comma-separated list of tags for your server.
# For example:
# - sets tags "drifting, cars, racing"
# Or:
# - sets tags "roleplay, military, tanks"
sets tags "default"
# A valid locale identifier for your server's primary language.
# For example "en-US", "fr-CA", "nl-NL", "de-DE", "en-GB", "pt-BR"
sets locale "root-AQ"
# please DO replace root-AQ on the line ABOVE with a real language! :)
# Set an optional server info and connecting banner image url.
# Size doesn't matter, any banner sized image will be fine.
#sets banner_detail "https://url.to/image.png"
#sets banner_connecting "https://url.to/image.png"
# Set your server's hostname
sv_hostname "FXServer, but unconfigured"
# Nested configs!
#exec server_internal.cfg
# Loading a server icon (96x96 PNG file)
#load_server_icon myLogo.png
# convars which can be used in scripts
set temp_convar "hey world!"
# Uncomment this line if you do not want your server to be listed in the server browser.
# Do not edit it if you *do* want your server listed.
#sv_master1 ""
# 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.fivem:1 group.admin # add the admin to the group
# Hide player endpoints in external log output.
sv_endpointprivacy true
# Server player slot limit (must be between 1 and 32, unless using OneSync)
sv_maxclients 32
# Steam Web API key, if you want to use Steam authentication (https://steamcommunity.com/dev/apikey)
# -> replace "" with the key
set steam_webApiKey ""
# License key for your server (https://keymaster.fivem.net)
sv_licenseKey changeme
EOF
Replace the script changeme
with the server key to deploy
start service
Start it with the following command:
cd /usr/local/src/FiveM/server-data
/usr/local/src/FiveM/server/run.sh +exec server.cfg
Remember, if the unavailable
/usr/local/src/FiveM/server/run.sh +exec /usr/local/src/FiveM/server-data/server.cfg
command starts, it will fail, and the specific reason is unknown
boot up
In order to achieve self-starting at boot, I adopted the Supervisor method (the systemctl method will restart infinitely, the reason is unknown):
first create a script to start the service /usr/local/src/FiveM/start.sh
:
cd /usr/local/src/FiveM/server-data && /usr/local/src/FiveM/server/run.sh +exec server.cfg
/etc/supervisor/conf.d/
Then create a new FiveM startup file in the Supervisor configuration folder fivem.conf
:
[program:fivem]
command=/usr/bin/bash /usr/local/src/FiveM/start.sh
directory=/usr/local/src/FiveM
user=root
stdout_logfile=/var/log/fivem.log
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
Last use supervisorctl reload
, select y
to start the FiveM service automatically
[root@centos ~]# supervisorctl status
fivem RUNNING pid 3316, uptime 5:24:59
The real-time logs are as follows (a heartbeat is sent every three minutes):
[root@centos ~]# tail /var/log/fivem.log -f
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Connection status (the server needs to add 30120 TCP and UDP inbound rules):
[root@VM_0_7_centos ~]# lsof -i:30120
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ld-musl-x 3317 root 28u IPv4 36571478 0t0 TCP VM_0_7_centos:30120->150.116.85.124:55130 (ESTABLISHED)
ld-musl-x 3317 root 31u IPv4 36470180 0t0 TCP *:30120 (LISTEN)
ld-musl-x 3317 root 33u IPv6 36470181 0t0 UDP *:30120
ld-musl-x 3317 root 35u IPv4 36476879 0t0 TCP VM_0_7_centos:30120->201.75.45.121:52624 (ESTABLISHED)
ld-musl-x 3317 root 36u IPv4 36477004 0t0 TCP VM_0_7_centos:30120->67.166.27.29:57882 (ESTABLISHED)
ld-musl-x 3317 root 37u IPv4 36509773 0t0 TCP VM_0_7_centos:30120->adria.kvarteto.net:50084 (ESTABLISHED)
ld-musl-x 3317 root 38u IPv4 36483951 0t0 TCP VM_0_7_centos:30120->cable-188-2-205-27.dynamic.sbb.rs:52447 (ESTABLISHED)
ld-musl-x 3317 root 39u IPv4 36484090 0t0 TCP VM_0_7_centos:30120->49.230.56.194:50631 (ESTABLISHED)
ld-musl-x 3317 root 40u IPv4 36571801 0t0 TCP VM_0_7_centos:30120->176.148.208.253:58608 (ESTABLISHED)
ld-musl-x 3317 root 41u IPv4 36484632 0t0 TCP VM_0_7_centos:30120->179.219.232.155:55005 (ESTABLISHED)
ld-musl-x 3317 root 42u IPv4 36488632 0t0 TCP VM_0_7_centos:30120->client-201.230.158.233.speedy.net.pe:13723 (ESTABLISHED)
ld-musl-x 3317 root 43u IPv4 36489318 0t0 TCP VM_0_7_centos:30120->112.201.139.65.pldt.net:ema-sent-lm (ESTABLISHED)
ld-musl-x 3317 root 44u IPv4 36504202 0t0 TCP VM_0_7_centos:30120->cpc69049-oxfd25-2-0-cust839.4-3.cable.virginm.net:55972 (ESTABLISHED)
ld-musl-x 3317 root 45u IPv4 36509900 0t0 TCP VM_0_7_centos:30120->106.203.63.106:64732 (ESTABLISHED)
ld-musl-x 3317 root 46u IPv4 36490560 0t0 TCP VM_0_7_centos:30120->177.155.219.25:58726 (ESTABLISHED)
ld-musl-x 3317 root 47u IPv4 36510686 0t0 TCP VM_0_7_centos:30120->187.21.113.230:51463 (ESTABLISHED)
ld-musl-x 3317 root 48u IPv4 36509557 0t0 TCP VM_0_7_centos:30120->pc-252-52-100-190.cm.vtr.net:50904 (ESTABLISHED)
ld-musl-x 3317 root 49u IPv4 36492966 0t0 TCP VM_0_7_centos:30120->170.254.133.248:4657 (ESTABLISHED)
ld-musl-x 3317 root 50u IPv4 36512199 0t0 TCP VM_0_7_centos:30120->93-86-107-145.dynamic.isp.telekom.rs:58530 (ESTABLISHED)
ld-musl-x 3317 root 51u IPv4 36523715 0t0 TCP VM_0_7_centos:30120->c-71-193-90-215.hsd1.mn.comcast.net:64846 (ESTABLISHED)
ld-musl-x 3317 root 52u IPv4 36515098 0t0 TCP VM_0_7_centos:30120->37.236.124.65:60517 (ESTABLISHED)
ld-musl-x 3317 root 53u IPv4 36524821 0t0 TCP VM_0_7_centos:30120->ppp-223-24-144-28.revip6.asianet.co.th:11693 (ESTABLISHED)
ld-musl-x 3317 root 54u IPv4 36522366 0t0 TCP VM_0_7_centos:30120->c-98-192-236-150.hsd1.de.comcast.net:58986 (ESTABLISHED)
ld-musl-x 3317 root 55u IPv4 36522517 0t0 TCP VM_0_7_centos:30120->190.200.255.39:17832 (ESTABLISHED)
ld-musl-x 3317 root 56u IPv4 36525992 0t0 TCP VM_0_7_centos:30120->cm-27-145-135-149.revip12.asianet.co.th:52631 (ESTABLISHED)
ld-musl-x 3317 root 57u IPv4 36531724 0t0 TCP VM_0_7_centos:30120->73.126.70.158:50722 (ESTABLISHED)
ld-musl-x 3317 root 58u IPv4 36555357 0t0 TCP VM_0_7_centos:30120->cpc139088-jarr15-2-0-cust109.16-2.cable.virginm.net:52928 (ESTABLISHED)
ld-musl-x 3317 root 59u IPv4 36531740 0t0 TCP VM_0_7_centos:30120->c-174-50-61-97.hsd1.la.comcast.net:52188 (ESTABLISHED)
ld-musl-x 3317 root 60u IPv4 36551137 0t0 TCP VM_0_7_centos:30120->187.21.84.137:65142 (ESTABLISHED)
ld-musl-x 3317 root 61u IPv4 36555172 0t0 TCP VM_0_7_centos:30120->77.202.162.69:54845 (ESTABLISHED)
ld-musl-x 3317 root 62u IPv4 36563973 0t0 TCP VM_0_7_centos:30120->199.199.246.200:63485 (ESTABLISHED)
Note: Because I put it on the server, the client connected to it not long after it was built
Resource usage: