2

Setup Spigot on Debian 10

 2 years ago
source link: https://www.vultr.com/docs/setup-spigot-on-debian-10
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
<?xml encoding="utf-8" ??>

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

1. Install Prerequisites

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-11-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 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 apt-get 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 $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK