Article

Table of Contents
Theme:
Was this article helpful?

0  out of  1 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $300 by adding new articles!

Setup Spigot on CentOS 7

Last Updated: Thu, Feb 25, 2021
CentOS Game Servers Minecraft

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 a Vultr CentOS 7 Server. It is recommended to run all commands as a non-root user with sudo privileges.

1. Install Prerequisites

Install the required prerequisite software.

$ sudo cat <<'EOF' > /etc/yum.repos.d/adoptopenjdk.repo
[AdoptOpenJDK]
name=AdoptOpenJDK
baseurl=http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
EOF

$ sudo yum install adoptopenjdk-11-hotspot -y
$ sudo yum install epel-release -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 installing Spigot.

$ cd ~

Create a folder for BuildTools.

$ mkdir buildtools && cd buildtools

Download BuildTools.jar.

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

Build Spigot 1.16.5. If you want to build a different version, replace 1.16.5 with the version desired.

$ 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 spigot && cd spigot

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

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

Create a start up script for your server.

$ nano start.sh

Paste the following into start.sh. The 4G parameters in -Xms4G -Xmx4G configure 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.

Edit eula.txt.

$ nano eula.txt

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

Start your server again.

$ ./start.sh

Optional: Run the server in the background

Install screen

$ sudo yum install screen -y

Open an instance of screen.

$ screen -S "spigot"

Start your server script.

$ cd ~/spigot
$ ./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.

Want to contribute?

You could earn up to $300 by adding new articles