Knowledgebase

Install Minecraft Spigot on Ubuntu 20.04 Print

  • 7

Install Spigot on Ubuntu 20.04

Last Updated: Thu, Sep 30, 2021 
Game ServersMinecraftUbuntu

Introduction

Spigot is a modification of the Minecraft server software, CraftBukkit. Spigot optimizes server resource usage, ensuring your players have the best experience and is also backwards compatible with most CraftBukkit modifications, allowing you to make your server unique. This guide explains how to set up Spigot on an Ubuntu Server. It is recommended to run all commands as a non-root user with sudo privileges.

1. Install Prerequisites

  • Buy vps cloud server instance from AG Host LTD.

  • sudo yum update

Install the required utilities.

$ sudo apt-get install wget apt-transport-https gnupg

Import the AdoptOpenJDK GPG key.

$ wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

Configure AdoptOpenJDK's apt repository.

$  echo "deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb $(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d = -f 2) main" | sudo tee /etc/apt/sources.list.d/adoptopenjdk.list

Refresh the package index.

$ sudo apt-get update

Install AdoptOpenJDK.

$ sudo apt-get install adoptopenjdk-16-hotspot -y

2. Create a Swapfile

Create a swap file. The example allocates a 1 GB file, set this value according to your needs.

$ sudo fallocate -l 1G /swapfile

Set the permissions of the swap file.

$ sudo chmod 600 /swapfile

Allocate the swap space.

$ sudo mkswap /swapfile

Turn on swap.

$ sudo swapon /swapfile

Make your swap file permanent by modifying the fstab file.

$ sudo nano /etc/fstab

Add this line to the bottom of the file.

/swapfile   none    swap    sw    0   0

3. Download and run BuildTools

Ensure you are in the home directory of the user used for building Spigot.

$ cd ~

Create a folder for Spigot and build the latest build. This example builds Spigot version 1.16.5. If you need a different version, replace 1.16.5 with the version you want to build.

$ mkdir buildtools && cd buildtools

$ wget -O BuildTools.jar  https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar

$ java -jar BuildTools.jar --rev 1.16.5

Make note of the name of your spigot jar file. For example, spigot-1.16.5.jar

$ ls

Make a directory for your server.

$ cd ~ && mkdir server && cd server

Move your spigot jar into your server directory. Replace spigotname.jar with the name of your file.

$ mv ~/buildtools/spigotname.jar ~/server/spigot.jar

4. Starting your server

Create a startup script for your server.

$ nano start.sh

Paste the following into start.sh. The 4G parameters in -Xms4G -Xmx4G configure the Java heapspace for 4 GB of RAM. Change this to the amount of RAM you want to allocate for Spigot. The operating system requires available RAM as well, please don't assign all available RAM to Spigot. For example, if the VPS has 8 GB RAM, you might consider setting -Xms7G -Xmx7G.

#!/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

Make start.sh executable.

$ chmod +x start.sh

Start your server.

$ ./start.sh

The first time it loads, it prompts you to accept the EULA and fails to load. The script then loops, and you need to type CTRL + C to exit the script at this point.

Accept the EULA.

$ nano eula.txt

Change eula= from false to true. Save and exit the file.

Start your server again.

$ ./start.sh

Optional: Run your server in the background

Install screen.

$ sudo apt-get install screen -y

Open an instance of screen.

$ screen -S "spigot"

Start your server script.

$ cd ~/server && ./start.sh

Configure your server's settings and install plugins.

Troubleshooting

If your spigot jar doesn't run, you need more RAM on your server or a larger swap file.


Was this answer helpful?
« Back