This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

FiveM Installation Tutorial

1. Grand Theft Auto V (GTA V)

Make sure you have a legal copy of Grand Theft Auto V installed on your computer. You can purchase GTA V from platforms like Steam, Rockstar Games, or other authorized retailers.

2. FiveM Account

Visit the FiveM website and create a FiveM account. You’ll need this account to log in to FiveM servers.

3. Download and Install FiveM

  • Go to the FiveM download page.
  • Click on the “Download Client” button.
  • Run the downloaded installer and follow the on-screen instructions.

4. Specify GTA V Location

During the installation process, you’ll be asked to locate your GTA V installation directory. Browse to the folder where GTA V is installed on your computer and select it.

5. Launch FiveM

After the installation is complete, launch FiveM from your desktop or start menu.

6. Update FiveM

FiveM may prompt you to update when you launch it. Allow the update to proceed to ensure you have the latest version.

7. Join a Server

  • Once FiveM is installed and up to date, click on the “Servers” tab in the main menu.
  • Browse through the available servers, choose one, and click “Connect.”

8. Install Mods (Optional)

Some servers may have custom mods or assets. Follow the server-specific instructions to install any additional mods required to join the server.

Note: Using mods or connecting to unofficial servers might violate the terms of service of GTA V, so proceed at your own risk. FiveM is a third-party modification and is not affiliated with Rockstar Games.

1 - Basic knowledge

Basic knowledge

CPU:

  • For a single FiveM server instance, you should allocate at least 4-6 CPU cores or vCPUs.
  • FiveM is heavily dependent on single-threaded performance, so a modern CPU with high clock speeds and strong per-core performance is recommended.
  • Intel Core i7 or AMD Ryzen 5/7 series CPUs are suitable for a single server instance.

RAM:

  • A single FiveM server instance typically requires 8-16 GB of RAM.
  • Higher RAM capacity is recommended if you plan to host a large number of players or resource-intensive custom scripts/mods.

Storage:

  • Allocate at least 100-200 GB of SSD storage for the game files, server data, and potential growth.
  • SSDs provide better I/O performance and reduced latency compared to traditional hard disk drives (HDDs).

Network:

  • A reliable and high-speed network connection is crucial for online gaming servers.
  • Gigabit Ethernet or faster network interfaces are recommended.
  • Low latency and consistent bandwidth are important for a smooth gaming experience.

Player Capacity and Performance:

  • The number of players on your FiveM server can significantly impact performance.
  • As the player count increases, the server will require more CPU, RAM, and network resources to handle the increased workload.
  • It’s essential to monitor resource utilization and adjust the hardware resources accordingly based on your target player capacity.
  • As a general guideline, for every 20-30 players, you may need to allocate an additional CPU core or vCPU and 2-4 GB of RAM.

Operating System and Docker Configuration:

  • Use a stable and efficient operating system like Linux (Ubuntu LTS, CentOS, etc.) or Windows Server, as they are designed for server workloads.
  • Ensure that the operating system is properly configured and optimized for Docker containers and gaming server workloads.
  • Configure Docker container resources (CPU, RAM, and storage) appropriately to match the server’s requirements.

It’s important to note that these are general recommendations, and your specific requirements may vary depending on the server configurations, custom scripts/mods, and other factors. It’s always a good idea to monitor resource utilization and performance during testing and adjust the hardware resources accordingly.

2 - Database

secure

2.1 - Secure Database Communication

Implement secure communication channels between game servers and the database using encryption, certificate-based authentication, IP restrictions, and role-based access control.

Use Encrypted Connections (SSL/TLS)

-- MySQL: Enable SSL/TLS for database connections
# 1. Generate SSL certificates
openssl genrsa 2048 > ca-key.pem
openssl req -new -x509 -nodes -days 3600 -key ca-key.pem -out ca.pem
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout server-key.pem -out server-req.pem
openssl rsa -in server-key.pem -out server-key.pem
openssl x509 -req -in server-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem

# 2. Configure MySQL to use SSL
[mysqld]
ssl-ca=ca.pem
ssl-cert=server-cert.pem
ssl-key=server-key.pem

# 3. Connect using SSL
mysql --ssl-ca=ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem
-- PostgreSQL: Enable SSL/TLS for database connections
# 1. Generate SSL certificates
openssl req -new -text -out server.req
openssl rsa -in privkey.pem -modulus -noout -out modulus
openssl req -x509 -in server.req -text -key privkey.pem -out server.crt
chmod og-rwx privkey.pem

# 2. Configure PostgreSQL to use SSL
ssl = on
ssl_cert_file = 'server.crt'
ssl_key_file = 'privkey.pem'

# 3. Connect using SSL
psql "host=localhost user=postgres sslmode=require"

Enforce Certificate-Based Authentication

-- MySQL: Configure certificate-based authentication
# 1. Generate client certificates
openssl req -newkey rsa:2048 -days 3600 -nodes -keyout client-key.pem -out client-req.pem
openssl rsa -in client-key.pem -out client-key.pem
openssl x509 -req -in client-req.pem -days 3600 -CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem

# 2. Configure MySQL to use certificate-based authentication
[mysqld]
ssl-ca=ca.pem
ssl-cert=server-cert.pem
ssl-key=server-key.pem

[client]
ssl-ca=ca.pem
ssl-cert=client-cert.pem
ssl-key=client-key.pem
-- PostgreSQL: Configure certificate-based authentication
# 1. Generate client certificates
openssl req -new -text -out client.req
openssl rsa -in privkey.pem -modulus -noout -out modulus
openssl req -x509 -in client.req -text -key privkey.pem -out client.crt

# 2. Configure PostgreSQL to use certificate-based authentication
hostssl all all 0.0.0.0/0 cert clientcert=1

Restrict Database Access to Specific IP Addresses/Networks

-- MySQL: Restrict access to specific IP addresses/networks
CREATE USER 'game_server'@'192.168.1.100' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON fivem.* TO 'game_server'@'192.168.1.100';
-- PostgreSQL: Restrict access to specific IP addresses/networks (pg_hba.conf)
host    fivem             game_server        192.168.1.100/32         md5

Implement Database User Roles and Permissions

-- MySQL: Create roles and assign permissions
CREATE ROLE fivem_read_only, fivem_data_entry, fivem_manager;

GRANT SELECT ON fivem.* TO fivem_read_only;
GRANT INSERT ON fivem.player_data TO fivem_data_entry;
GRANT INSERT, UPDATE, DELETE ON fivem.* TO fivem_manager;

CREATE USER 'game_viewer'@'192.168.1.100' IDENTIFIED BY 'StrongPassword123!';
GRANT fivem_read_only TO 'game_viewer'@'192.168.1.100';
-- PostgreSQL: Create roles and assign permissions
CREATE ROLE fivem_read_only;
GRANT SELECT ON ALL TABLES IN SCHEMA fivem TO fivem_read_only;

CREATE ROLE fivem_data_entry;
GRANT INSERT ON fivem.player_data TO fivem_data_entry;

CREATE ROLE fivem_manager;
GRANT INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA fivem TO fivem_manager;

CREATE USER game_viewer WITH PASSWORD 'StrongPassword123!';
GRANT fivem_read_only TO game_viewer;

2.2 - Database Server Hardening

Harden your database server by disabling unnecessary services, enabling firewalls, implementing strong authentication, and enabling auditing and logging.

Disable or Remove Unnecessary Services and Features

-- MySQL: Disable unnecessary components during installation
# For MySQL 8.0, add the following options during installation:
mysqld=--skip-profiling,--skip-perfschema

# For existing installations, you can disable components in the my.cnf file:
skip-perfschema
skip-profiling
# PostgreSQL: Disable unnecessary components during installation
# Add the following options to the postgresql.conf file:
shared_preload_libraries = '' # Disables all preloaded libraries

Enable Database Server’s Built-in Firewall

-- MySQL: Enable and configure the built-in firewall
# Enable the firewall
INSTALL SONAME 'MYSQLX_FIREWALL';

# Create a whitelist for allowed IP addresses
MYSQLX_FIREWALL_INSTALL(
    'WHITELIST_INET',
    'WHITELIST_USERS',
    'client_ip=192.168.1.0/24,127.0.0.1, user=fivem_viewer,fivem_entry,fivem_admin'
);

# Start the firewall
MYSQLX_FIREWALL_ACTIVATE();
-- PostgreSQL: Enable and configure the built-in firewall (pg_hba.conf)
# Allow connections from specific IP addresses
host    all             all             192.168.1.0/24            md5
host    all             all             127.0.0.1/32               md5

# Deny all other connections
host    all             all             0.0.0.0/0                 reject

Implement Strong Authentication and Least Privilege

-- Create users with strong passwords and assign roles
CREATE USER 'fivem_viewer'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT fivem_read_only TO 'fivem_viewer'@'localhost';

CREATE USER 'fivem_entry'@'localhost' IDENTIFIED BY 'AnotherStrongPass!';
GRANT fivem_data_entry TO 'fivem_entry'@'localhost';

CREATE USER 'fivem_admin'@'localhost' IDENTIFIED BY 'SuperSecurePass123!';
GRANT fivem_manager TO 'fivem_admin'@'localhost';

Enable Auditing and Logging

-- MySQL: Enable and configure audit logging
INSTALL SONAME 'server_audit';
SET GLOBAL server_audit_logging=ON;
SET GLOBAL server_audit_file_rotate_size=1000000; # Rotate log files at 1MB
SET GLOBAL server_audit_file_rotate_max_retained_files=10; # Keep 10 log files

-- Configure log events to capture
SET GLOBAL server_audit_events='CONNECT,QUERY';
-- PostgreSQL: Enable and configure logging
# Edit the postgresql.conf file
log_destination = 'csvlog'
logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_truncate_on_rotation = off
log_rotation_age = 1d
log_rotation_size = 100000 # Rotate log files at 100MB

2.3 - Database Access Monitoring

Monitor database activities, implement intrusion detection/prevention systems, set up alerts for potential threats, and regularly review logs to ensure the security of your database.

Enable Database Activity Logging

-- MySQL: Enable and configure audit logging
INSTALL SONAME 'server_audit';
SET GLOBAL server_audit_logging=ON;
SET GLOBAL server_audit_file_rotate_size=1000000; # Rotate log files at 1MB
SET GLOBAL server_audit_file_rotate_max_retained_files=10; # Keep 10 log files

-- Configure log events to capture
SET GLOBAL server_audit_events='CONNECT,QUERY';
-- PostgreSQL: Enable and configure logging
# Edit the postgresql.conf file
log_destination = 'csvlog'
logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_truncate_on_rotation = off
log_rotation_age = 1d
log_rotation_size = 100000 # Rotate log files at 100MB

Implement Intrusion Detection/Prevention Systems (IDS/IPS)

# Install and configure an IDS/IPS solution like Snort or Suricata
# Example for Snort on Ubuntu
sudo apt-get install snort

# Configure Snort to monitor database traffic
# Edit the snort.conf file
ipvar HOME_NET 192.168.1.0/24
ipvar EXTERNAL_NET !$HOME_NET

# Add rules to detect potential threats
include $RULE_PATH/mysql.rules
include $RULE_PATH/postgresql.rules
include $RULE_PATH/sql-injection.rules

# Start Snort in IDS mode
sudo snort -A console -q -u snort -g snort -c /etc/snort/snort.conf -i eth0

Set up Alerts for Potential Threats

-- MySQL: Set up alerts for failed login attempts and SQL injection
DELIMITER $$
CREATE TRIGGER failed_login_attempts_trigger
AFTER INSERT ON mysql.general_log
FOR EACH ROW
BEGIN
    IF NEW.argument LIKE 'ACCESS DENIED%' THEN
        INSERT INTO failed_login_attempts (user, host, timestamp)
        VALUES (SUBSTRING_INDEX(NEW.argument, '@', 1),
                SUBSTRING_INDEX(SUBSTRING_INDEX(NEW.argument, '@', -1), ']', 1),
                NEW.event_time);
    END IF;
END$$
DELIMITER ;

DELIMITER $$
CREATE TRIGGER sql_injection_attempts_trigger
AFTER INSERT ON mysql.general_log
FOR EACH ROW
BEGIN
    IF NEW.argument RLIKE '(^(\\\\\\\'|\\\'|\\%27|\')|\\b(union|select|insert|update|delete)\\b.*(\\b(from|into)\\b.*(\\b(information_schema|mysql|sys|data)\\b|\\bconcaten\\(|\\bchar\\())|\\b(outfile|load_file|into|dumpfile))' THEN
        INSERT INTO sql_injection_attempts (user, host, query, timestamp)
        VALUES (SUBSTRING_INDEX(NEW.argument, '@', 1),
                SUBSTRING_INDEX(SUBSTRING_INDEX(NEW.argument, '@', -1), ']', 1),
                NEW.argument,
                NEW.event_time);
    END IF;
END$$
DELIMITER ;
-- PostgreSQL: Set up alerts for failed login attempts and SQL injection
CREATE EXTENSION IF NOT EXISTS log_fdw;

CREATE SERVER log_server
FOREIGN DATA WRAPPER log_fdw
OPTIONS (filename '/var/log/postgresql/postgresql-%Y-%m-%d_%H%M%S.log');

CREATE TABLE failed_login_attempts (
    username TEXT,
    client_addr TEXT,
    timestamp TIMESTAMP
);

CREATE RULE failed_login_alert AS
ON INSERT TO failed_login_attempts
WHERE NEW.username IS NOT NULL
DO NOTIFY failed_login_attempt,
           E'Username: ' || NEW.username || E'\nClient Address: ' || NEW.client_addr || E'\nTimestamp: ' || NEW.timestamp;

CREATE VIEW failed_logins WITH (security_barrier) AS
SELECT
    split_part(message, ' ', 10) AS username,
    split_part(message, ' ', 11) AS client_addr,
    timestamp
FROM pg_log.postgresql_log
WHERE message LIKE 'FATAL%password authentication failed for user%';

Regularly Review and Analyze Logs

# Analyze MySQL audit logs
sudo mysqlauditgrep --query-log=/var/log/mysql/audit.log --query-pam-ksok --query-has-comment-augment --query-has-sleep-augment --query-has-delay-augment

# Analyze PostgreSQL logs
sudo grep 'FATAL' /var/log/postgresql/*.log | awk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11}'

2.4 - Secure FiveM Server Database

Implement robust security measures to protect your FiveM server’s database from potential attacks and unauthorized access.

User Account Management

Principle of Least Privilege

-- Create roles for FiveM server operations
CREATE ROLE fivem_read_only, fivem_data_entry, fivem_manager;

-- Grant minimum required permissions to each role
GRANT SELECT ON fivem.* TO fivem_read_only;
GRANT INSERT ON fivem.player_data TO fivem_data_entry;
GRANT INSERT, UPDATE, DELETE ON fivem.* TO fivem_manager;

-- Create users and assign roles
CREATE USER 'fivem_viewer'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT fivem_read_only TO 'fivem_viewer'@'localhost';

CREATE USER 'fivem_entry'@'localhost' IDENTIFIED BY 'AnotherStrongPass!';
GRANT fivem_data_entry TO 'fivem_entry'@'localhost';

CREATE USER 'fivem_admin'@'localhost' IDENTIFIED BY 'SuperSecurePass123!';
GRANT fivem_manager TO 'fivem_admin'@'localhost';

Strong Password Policies

-- Enforce a strong password policy
SET GLOBAL validate_password.length=14;
SET GLOBAL validate_password.number_count=2;
SET GLOBAL validate_password.mixed_case_count=1;
SET GLOBAL validate_password.special_char_count=1;
SET GLOBAL validate_password.dictionary_file='/usr/share/mysql/english_dictionary.txt';

-- Update user password to comply with the new policy
ALTER USER 'fivem_viewer'@'localhost' IDENTIFIED BY 'N3wStr0ngPa$$word';

Multi-Factor Authentication (MFA)

-- Install the MFA plugin
INSTALL PLUGIN authentication_mfa SONAME 'authentication_mfa.so';

-- Create an MFA-enabled user account
CREATE USER 'fivem_superadmin'@'localhost' IDENTIFIED BY 'UltraSecurePass123!';

-- Configure MFA for the user, using a hardware security key
ALTER USER 'fivem_superadmin'@'localhost'
IDENTIFIED WITH authentication_mfa
BY 'initial_secret_key'
REQUIRE SECURE_REMOTE_USER;

Database Permissions

Role-Based Access Control (RBAC)

-- Create a role for FiveM server developers
CREATE ROLE fivem_developer;
GRANT SELECT, INSERT, UPDATE ON fivem.resources TO fivem_developer;

-- Assign the role to a user
GRANT fivem_developer TO 'dev_user'@'%';

Granular Permissions

-- Grant SELECT permission on specific tables
GRANT SELECT ON fivem.player_data, fivem.server_logs TO 'fivem_viewer'@'%';

-- Grant INSERT permission on specific columns
GRANT INSERT(name, score) ON fivem.player_scores TO 'fivem_entry'@'%';

Secure Database Objects

-- Create a stored procedure for inserting player scores
DELIMITER $$
CREATE PROCEDURE InsertPlayerScore(
    IN p_name VARCHAR(50),
    IN p_score INT
)
BEGIN
    -- Input validation
    IF p_score < 0 THEN
        SIGNAL SQLSTATE '45000'
            SET MESSAGE_TEXT = 'Score cannot be negative';
    END IF;

    -- Check if player exists
    IF NOT EXISTS (SELECT 1 FROM player_data WHERE name = p_name) THEN
        SIGNAL SQLSTATE '45000'
            SET MESSAGE_TEXT = 'Player does not exist';
    END IF;

    -- Insert score
    INSERT INTO player_scores (name, score)
    VALUES (p_name, p_score);
END$$
DELIMITER ;

-- Grant execute permission on the stored procedure
GRANT EXECUTE ON PROCEDURE InsertPlayerScore TO 'fivem_entry'@'%';
-- Create a view that masks sensitive player data
CREATE VIEW player_data_public AS
SELECT name, game_id, join_date
FROM player_data;

-- Grant SELECT permission on the view
GRANT SELECT ON player_data_public TO 'fivem_viewer'@'%';

3 - FiveM Installation

Learn how to install FiveM on your Windows PC.

FiveM Installation

Welcome to the FiveM installation guide. Follow the steps below to get started:

  1. Grand Theft Auto V (GTA V)

    • Make sure you have a legal copy of Grand Theft Auto V installed on your computer.
  2. FiveM Account

    • Visit the FiveM website and create a FiveM account. You’ll need this account to log in to FiveM servers.

  1. Install Mods (Optional)
    • Some servers may have custom mods or assets. Follow the server-specific instructions to install any additional mods required to join the server.

Note: Using mods or connecting to unofficial servers might violate the terms of service of GTA V, so proceed at your own risk. FiveM is a third-party modification and is not affiliated with Rockstar Games.

Always follow the rules and guidelines of the server you’re playing on, and have fun exploring the various multiplayer experiences that FiveM offers!

Back to Home

FiveM Installation Tutorial

1. Grand Theft Auto V (GTA V)

Make sure you have a legal copy of Grand Theft Auto V installed on your computer. You can purchase GTA V from platforms like Steam, Rockstar Games, or other authorized retailers.

2. FiveM Account

Visit the FiveM website and create a FiveM account. You’ll need this account to log in to FiveM servers.

3. Download and Install FiveM

  • Go to the FiveM download page.
  • Click on the “Download Client” button.
  • Run the downloaded installer and follow the on-screen instructions.

4. Specify GTA V Location

During the installation process, you’ll be asked to locate your GTA V installation directory. Browse to the folder where GTA V is installed on your computer and select it.

5. Launch FiveM

After the installation is complete, launch FiveM from your desktop or start menu.

6. Update FiveM

FiveM may prompt you to update when you launch it. Allow the update to proceed to ensure you have the latest version.

7. Join a Server

  • Once FiveM is installed and up to date, click on the “Servers” tab in the main menu.
  • Browse through the available servers, choose one, and click “Connect.”

8. Install Mods (Optional)

Some servers may have custom mods or assets. Follow the server-specific instructions to install any additional mods required to join the server.

Note: Using mods or connecting to unofficial servers might violate the terms of service of GTA V, so proceed at your own risk. FiveM is a third-party modification and is not affiliated with Rockstar Games.

4 - FiveM Server Tutorials for GTA V

Comprehensive guides to help you set up and manage your own FiveM servers for GTA V.

Welcome to the FiveM Server Tutorials

Explore our detailed tutorials designed to assist you in setting up and managing your FiveM servers for Grand Theft Auto V. Perfect for both beginners and experienced server administrators, these guides cover everything from basic setup to advanced configurations.

Tutorials

Getting Started

To begin, choose the tutorial that corresponds to your operating system and follow the instructions carefully. Each guide is designed to be easy to understand and will walk you through the process from start to finish.

Need Help?

If you encounter any issues or have questions, don’t hesitate to visit our community support forum for assistance.

Happy gaming and server managing!

4.1 - Installing a FiveM Server on CentOS

This tutorial will guide you through the process of installing a FiveM server on a CentOS operating system.

Installing a FiveM Server on CentOS

Prerequisites

  • A server running CentOS.
  • Root or sudo access on the server.
  • Basic knowledge of the Linux command-line interface.

Step 1: Installing Dependencies

  1. Update your system:

    sudo yum update
    
  2. Install the EPEL repository:

    sudo yum install epel-release
    
  3. Install required packages:

    sudo yum install git curl screen xz wget -y
    

Step 2: Adding a New User for FiveM

It’s recommended to run the FiveM server as a separate user for security purposes.

  1. Create a new user:

    sudo adduser fivem
    
  2. Switch to the new user:

    su - fivem
    

Step 3: Downloading and Extracting FiveM Server Files

  1. Download the latest server artifact:

    wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/latest.tar.xz
    
  2. Extract the server files:

    tar xf latest.tar.xz
    

Step 4: Configuring the Server

  1. Create a server configuration file (server.cfg):

    nano server.cfg
    
  2. Add basic configuration settings to server.cfg. Refer to the FiveM documentation for sample configurations.

  3. Save and exit the nano editor.

Step 5: Running the Server

  1. Start the server using the screen utility:
    screen -S fivem-server ./run.sh +exec server.cfg
    

Step 6: Server Management

  • To detach from the screen session, press Ctrl+A followed by Ctrl+D.
  • To return to the session, use screen -r fivem-server.

Conclusion

Your FiveM server should now be operational on CentOS. Always manage your server responsibly and in compliance with FiveM’s terms of service.


For detailed configuration options and more advanced settings, consult the FiveM Documentation.

4.2 - Setting Up a FiveM Server on Debian

A comprehensive guide to setting up a FiveM server on a Debian-based system.

Setting Up a FiveM Server on Debian

Creating a FiveM server on a Debian server involves several steps. This guide will walk you through the process from start to finish.

Prerequisites

  • A server running Debian or a Debian-based Linux distribution.
  • Root or sudo access on the server.
  • Basic knowledge of Linux command-line interface.

Step 1: Installing Dependencies

Before installing the FiveM server, you need to install the required dependencies.

  1. Update your package lists:

    sudo apt update
    
  2. Install the necessary packages:

    sudo apt install git curl screen xz-utils wget -y
    

Step 2: Creating a User for FiveM

It’s a good practice to run services like FiveM under a separate user.

  1. Create a new user:

    sudo adduser fivem
    
  2. Switch to the new user:

    su - fivem
    

Step 3: Downloading and Preparing FiveM Server Files

  1. Download the latest server artifact:

    wget https://runtime.fivem.net/artifacts/fivem/build_proot_linux/master/latest.tar.xz
    
  2. Extract the server files:

    tar xf latest.tar.xz
    
  3. Clone the cfx-server-data repository from GitHub. This repository contains essential data for your FiveM server:

    git clone https://github.com/citizenfx/cfx-server-data.git
    
  4. Move the resources folder from cfx-server-data to your main FiveM server directory:

    mv cfx-server-data/resources /home/fivem/
    
  5. Remove the now-empty resources directory from cfx-server-data:

    rm -rf cfx-server-data/resources
    

Step 4: Configuring the Server

  1. Create a new configuration file (server.cfg):

    nano 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 basic-gamemode
    ensure hardcap
    ensure rconlog
    
    # 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. This is not usually shown anywhere in listings.
    sv_hostname "FXServer, but unconfigured"
    
    # Set your server's Project Name
    sets sv_projectName "My FXServer Project"
    
    # Set your server's Project Description
    sets sv_projectDesc "Default FXServer requiring configuration"
    
    # Set Game Build (https://docs.fivem.net/docs/server-manual/server-commands/#sv_enforcegamebuild-build)
    #sv_enforceGameBuild 2802
    
    # 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!"
    
    # Remove the `#` from the below line if you want your server to be listed as 'private' in the server browser.
    # Do not edit it if you *do not* want your server listed as 'private'.
    # Check the following url for more detailed information about this:
    # https://docs.fivem.net/docs/server-manual/server-commands/#sv_master1-newvalue
    #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
    
    # enable OneSync (required for server-side state awareness)
    set onesync on
    
    # Server player slot limit (see https://fivem.net/server-hosting for limits)
    sv_maxclients 48
    
    # 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
    
  2. Populate the configuration file. A basic example can be found in the FiveM documentation.

  3. Save and exit the editor:

    • Once you have finished editing the file in nano, you need to save your changes. To do this, press Ctrl + O. This command stands for ‘write Out’, which is nano’s way of saying ‘save’.
    • After pressing Ctrl + O, nano will ask you to confirm the file name. By default, it will use the name of the file you’re editing. Simply press Enter to confirm.
    • Now that your changes are saved, you can exit nano. Press Ctrl + X to close the editor and return to the command prompt.

Step 5: Configuring Firewall for FiveM

Before enabling the firewall, it’s important to ensure you won’t lose remote access to your server, especially if you’re using SSH.

  1. Check if UFW (Uncomplicated Firewall) is installed:

    sudo apt install ufw
    
  2. Allow SSH connections to ensure you can still access your server after the firewall is enabled:

    sudo ufw allow 22/tcp
    
  3. Enable UFW:

    sudo ufw enable
    
  4. Allow the default FiveM ports. FiveM typically uses ports 30120 and 30110 for server and HTTP server:

    sudo ufw allow 30120/tcp
    sudo ufw allow 30110/tcp
    
  5. Optionally, if you are using additional ports for specific resources or services, open them similarly:

    sudo ufw allow [YourAdditionalPort]/tcp
    
  6. Check your UFW status to ensure the rules are applied:

    sudo ufw status
    

Step 6: Running the Server

  1. Start the server using screen for background execution:
    screen -S fivem-server ./run.sh +exec server.cfg
    

cd ~/FXServer/server-data && bash ~/FXServer/server/run.sh +exec server.cfg

Step 6: Managing Your Server

  • To detach from the screen session, press Ctrl+A then Ctrl+D.
  • To reattach to the session, use screen -r fivem-server.

Conclusion

You have now set up a FiveM server on Debian. Remember to manage your server responsibly and adhere to the FiveM terms of service.


For more advanced configurations and troubleshooting, refer to the FiveM Documentation.

4.3 - Creating a FiveM Server on Windows

A step-by-step guide to setting up a FiveM server on your Windows PC.

Creating a FiveM Server on Windows

This guide will walk you through the steps to set up a FiveM server on your Windows PC.

Prerequisites

  • A PC running Windows.
  • A copy of Grand Theft Auto V installed.
  • Administrative access on your PC.

Step 1: Downloading FiveM Server Files

  1. Visit the FiveM website: FiveM.net
  2. Download the server files.
  3. Extract the downloaded files into a folder where you want your server to be located.

Step 2: Configuring the Server

  1. Navigate to the folder where you extracted the server files.
  2. Create a new text document named server.cfg.
  3. Edit server.cfg to configure your server settings. You can find a sample configuration on the FiveM documentation page.

Step 3: Running the Server

  1. Open the folder where your server files are located.
  2. Run FXServer.exe.
  3. Your server should now start. Ensure that your firewall allows incoming and outgoing connections for FiveM.

Step 4: Connecting to Your Server

  1. Open FiveM.
  2. Go to the server browser.
  3. Search for your server by name.
  4. Connect and start playing.

Additional Configuration

  • Adding Mods: You can add mods by placing their files in the resources folder and configuring them in your server.cfg.
  • Server Administration: Consider using a resource like txAdmin for easier server management.

Remember, running a server can require a significant amount of resources depending on the number of players and mods you plan to use.

Conclusion

Setting up a FiveM server can be a fun way to customize your GTA V experience. Always ensure you respect the game’s and FiveM’s terms of service when operating your server.


This tutorial is a basic guide. For more detailed instructions and advanced configurations, refer to the FiveM Documentation.