How to Run Two Servers on One Machine: Setting Up a Dev Server
Learn how to duplicate your FiveM server to create a developer environment on the same machine without interfering with your live server.

Author: Goodleaf Hosting

Running a live server and a development server on the same machine is an efficient way to test features and fixes without disrupting your main community. This guide will walk you through setting up a duplicate "dev server" with its own configuration, ports, and database.


Step 1: Duplicate Your Server Files

To ensure your dev server matches your live server, make an exact copy of your current server files.

How to Duplicate:

  1. Navigate to your live server’s folder.
  2. Copy the entire directory.
  3. Paste it into a new location and rename it (e.g., QBCoreDev).

Why Duplicate?
This ensures your dev server mirrors the live server, making it the ideal environment for testing changes.


Step 2: Modify Your Ports

Each server must use unique ports to avoid conflicts.

Steps to Change Ports:

  1. Open the duplicated server’s server.cfg file.
  2. Find and modify the ports for the new server:
    endpoint_add_tcp "0.0.0.0:30121"
    endpoint_add_udp "0.0.0.0:30121"
    
  3. Save the file.

Note: 30121 is a commonly used port for dev servers, but you can choose another unused port if needed.


Step 3: Update the License Key

FiveM requires a unique license key for each server.

Steps to Update the Key:

  1. Visit the FiveM Keymaster.
  2. Generate a new key for your dev server.
  3. Replace the sv_licenseKey value in your duplicated server.cfg file with the new key:
    sv_licenseKey "new_license_key"
    

Step 4: Create a Batch File to Run the Dev Server

A batch file simplifies launching your dev server.

How to Create a Batch File:

  1. Open Notepad and paste the following code:
    @echo off
    "C:\QBCoreDev//FXServer.exe" +set serverProfile "dev_server" +set txAdminPort 40125
    pause
    
  2. Replace C:\QBCoreDev with the path to your duplicated server’s FXServer.exe file.
  3. Save the file as devserver.bat on your desktop.
  4. Double-click the .bat file to start your dev server.

Key Points:

  • The +set txAdminPort 40125 ensures txAdmin uses a unique port for the dev server.
  • If 40125 is already in use, choose another unused port.

Step 5: Install txAdmin on the Dev Server

Follow the prompts when starting the dev server to install txAdmin.

Tips for txAdmin Setup:

  • If txAdmin reports that ports are in use, change the port in your batch file and retry.
  • Open ports 40125 (txAdmin) and 30121 (server endpoint) in your firewall.

Step 6: Configure a Separate Database

Your dev server should not use the same database as your live server to prevent accidental changes.

How to Create a Separate Database:

  1. Export your live server’s database.
  2. Import it under a new name (e.g., dev_database).
  3. Update the server.cfg of your dev server to point to the new database:
    set mysql_connection_string "server=127.0.0.1;database=dev_database;userid=root;password=your_password"
    

Why Separate Databases?
This prevents testing changes from affecting live data.


Final Checklist

  • Duplicate Files: Ensure all server files are copied correctly.
  • Unique Ports: Confirm ports for both servers don’t overlap.
  • New License Key: Use a separate key for the dev server.
  • Separate Database: Create a cloned database to avoid affecting live server data.
  • Firewall Rules: Open all necessary ports for the dev server to function.

Optional: Virtualization

For added safety and isolation, you can run the dev server in a virtualized environment. Virtualization keeps the dev server completely separate from your live server, even on the same machine.

Need Help? Goodleaf Hosting offers professional virtualization setup services to help you securely run multiple servers on one machine.


Final Thoughts

Running a dev server alongside your live server is an excellent way to test new features and fixes without disrupting your main community. By following this guide, you can efficiently manage two servers on one machine, ensuring both stability and flexibility.

Looking for optimized hosting solutions? Goodleaf Hosting provides high-performance servers tailored for FiveM, supporting both live and dev environments with ease. Get started today!

Esta resposta foi útil? 0 Utilizadores acharam útil (0 Votos)