How to Install Spigot on Ubuntu 24.04

Updated on 31 July, 2025
Learn how to install Spigot on Ubuntu 20.04. Optimize Minecraft server performance with this easy-to-follow, step-by-step guide.
How to Install Spigot on Ubuntu 24.04 header image

Spigot is a high-performance, open-source Minecraft server implementation built on top of CraftBukkit. It improves server efficiency, supports most Bukkit plugins, and allows you to customize gameplay using plugins and configuration tweaks.

In this article, you will install and configure a Spigot server on Ubuntu 24.04, set up Java, allocate system resources, and launch the server with a custom startup script. This setup provides a reliable foundation for hosting Minecraft multiplayer worlds with plugin support.

Prerequisites

Before you begin, ensure you have:

Install Prerequisites

Install the required system tools and Java runtime environment to build and run Spigot.

  1. Install essential utilities.

    console
    $ sudo apt install wget apt-transport-https gnupg software-properties-common -y
    
  2. Install OpenJDK 17 (LTS), the recommended Java version for modern Minecraft servers.

    console
    $ sudo apt install openjdk-17-jdk-headless -y
    
  3. Confirm the Java installation.

    console
    $ java -version
    

    Output:

    openjdk version "17.0.15" 2025-04-15
    OpenJDK Runtime Environment (build 17.0.15+6-Ubuntu-0ubuntu124.04)

Create a Swapfile

Add a swap file to extend your server's virtual memory, which improves stability when running resource-intensive tasks like Spigot.

On Ubuntu 24.04, a default swap file (e.g., 2–5 GB) is typically preconfigured. You can skip creating a swap file unless you need to increase the available swap memory manually.

  1. Create a 1 GB swap file. You can adjust the size as needed.

    console
    $ sudo fallocate -l 1G /swapfile
    
  2. Set the correct file permissions.

    console
    $ sudo chmod 600 /swapfile
    
  3. Format the file as swap.

    console
    $ sudo mkswap /swapfile
    
  4. Enable the swap file.

    console
    $ sudo swapon /swapfile
    
  5. Make the swap permanent by editing the fstab file.

    console
    $ sudo nano /etc/fstab
    
  6. Add the following line at the end of the file:

    ini
    /swapfile   none    swap    sw    0   0
    

Download and Build Spigot

Download Spigot's BuildTools utility and compile the Spigot server JAR.

  1. Create a folder for building Spigot and switch into it.

    console
    $ mkdir buildtools
    
    console
    $ cd buildtools
    
  2. Download the latest BuildTools JAR file from the official Spigot repository.

    console
    $ wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
    
  3. Build Spigot version 1.20.4 (or replace with the version you want).

    console
    $ java -jar BuildTools.jar --rev 1.20.4
    
  4. After the build completes, list the output to find the generated Spigot JAR.

    console
    $ ls
    

    The output will include a file named spigot-1.20.4.jar.

  5. Create a directory to host your Spigot server and navigate to it.

    console
    $ mkdir -p ~/server
    
    console
    $ cd ~/server
    
  6. Move the compiled Spigot JAR into the server directory.

    console
    $ mv ~/buildtools/spigot-1.20.4.jar ~/server/spigot.jar
    

Start the Server

Create a startup script and launch the Spigot server for the first time.

  1. Create a new startup script.

    console
    $ nano start.sh
    
  2. Paste the following content into the file. This script allocates 4 GB of RAM to Spigot and automatically restarts the server on failure.

    Note
    Adjust -Xms4G -Xmx4G to match the amount of memory you want to allocate. For example, on a server with 8 GB RAM, use -Xms6G -Xmx6G to leave enough memory for the operating system.
    bash
    #!/bin/sh
    while true
    do
    java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar spigot.jar nogui
    echo "restarting in 10"
    sleep 10
    done
    
  3. Save the file and make it executable.

    console
    $ chmod +x start.sh
    
  4. Start the server.

    console
    $ ./start.sh
    

    The first run generates configuration files and exits with an EULA error. Press Ctrl + C to stop the loop when you see the message.

  5. Open the eula.txt file.

    console
    $ nano eula.txt
    
  6. Change the following line:

    ini
    eula=false
    

    to:

    ini
    eula=true
    

    Save and close the file.

  7. Start the server again.

    console
    $ ./start.sh
    
  8. If you want other players to join your Minecraft server, allow traffic through UFW on port 25565.

    console
    $ sudo ufw allow 25565/tcp
    
    console
    $ sudo ufw reload
    
  9. Verify that the rule is applied.

    console
    $ sudo ufw status
    

    Output:

    25565/tcp                  ALLOW       Anywhere
Run Your Server in the Background (Optional)

Use screen to run your Minecraft server in the background, allowing it to continue running after you disconnect from SSH.

  1. Install screen if it's not already available.

    console
    $ sudo apt install screen -y
    
  2. Start a new screen session named spigot.

    console
    $ screen -S spigot
    
  3. Start the server inside the screen session.

    console
    $ cd ~/server
    
    console
    $ ./start.sh
    
  4. To detach from the session and leave the server running, press Ctrl + A, then D.

  5. To return to the session later:

    console
    $ screen -r spigot
    

You can now configure your server settings and install plugins while the server runs in the background.

Conclusion

In this article, you installed and configured a Spigot Minecraft server on Ubuntu 24.04. You set up Java, built the Spigot JAR using BuildTools, created a startup script, and launched the server. You also enabled persistent background execution with screen.

With your Spigot server running, you can now install plugins, configure gameplay settings, and invite players to join your custom Minecraft world.

Comments

No comments yet.