Spigot is a modified Minecraft server software based on CraftBukkit. It provides additional performance optimizations, configuration options and features while maintaining compatibility with all existing plugins and mods.
In this tutorial, you will learn how to build and install Spigot Server on a Ubuntu 20.04 based server and install plugins.
Prerequisites
-
A server running Ubuntu 20.04 with a minimum of 4GB RAM and 2 CPU Cores.
-
A non-root user with sudo privileges.
-
Everything is updated.
$ sudo apt update && sudo apt upgrade
-
Install the required packages.
$ sudo apt install wget apt-transport-https gnupg nano screen
Step 1 - Configure Firewall
The first step is to configure the firewall. Ubuntu comes with ufw (Uncomplicated Firewall) by default.
Check if the firewall is running.
$ sudo ufw status
You should get the following output.
Status: inactive
Allow SSH port to prevent the firewall from breaking the current connection on enabling it.
$ sudo ufw allow OpenSSH
Allow port 25565 for the Spigot server to accept connections.
$ sudo ufw allow 25565
Enable the Firewall
$ sudo ufw enable Command may disrupt existing ssh connections. Proceed with operation (y|n)? y Firewall is active and enabled on system startup
Check the status of the firewall again.
$ sudo ufw status
You should see a similar output.
Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere 25565 ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) 25565 (v6) ALLOW Anywhere (v6)
Step 2 - Install Java and Git
Spigot installer needs Java and Git to work. Ubuntu 20.04 ships with OpenJDK 17 as the latest available version of Java. Run the following command to install it.
$ sudo apt install openjdk-17-jre-headless
Confirm the release.
$ java --version openjdk 17.0.1 2021-10-19 OpenJDK Runtime Environment (build 17.0.1+12-Ubuntu-120.04) OpenJDK 64-Bit Server VM (build 17.0.1+12-Ubuntu-120.04, mixed mode, sharing)
Install Git.
$ sudo apt install git
Step 3 - Create a Minecraft user
The next step is to create a dedicated user for running the server.
$ sudo adduser minecraft
Switch to the newly created user.
$ sudo su - minecraft
Step 4 - Download and install Spigot
We will build Spigot using the BuildTools.jar application. The first step is to switch to the home directory.
minecraft:$ cd ~
Create a new directory for BuildTools and shift to it.
minecraft:$ mkdir buildtools && cd buildtools
Grab the BuildTools.jar
file.
minecraft:$ wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
Build the latest stable version of Spigot.
minecraft:$ java -jar BuildTools.jar --rev latest
Depending on the available server resources, this process may take time to complete.
Check the name of the Spigot jar file created.
minecraft:$ ls apache-maven-3.6.0 BuildData BuildTools.jar BuildTools.log.txt Bukkit CraftBukkit Spigot spigot-1.18.1.jar work
In our case, the name is.
Create another directory for your Spigot Server and switch to it.
minecraft:$ cd ~ && mkdir server && cd server
Move your Spigot jar file to the newly created server directory.
minecraft:$ mv ~/buildtools/spigot-1.18.1.jar ~/server/spigot.jar
Step 5 - Start Spigot Server
To start the Spigot server, we need to create a startup script that allows us to pass various Java parameters to optimize the server.
Create and open the startup script for Spigot.
minecraft:$ sudo nano spigotstart.sh
Paste the following code in the file.
#!/bin/sh java -Xms3G -Xmx3G -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
The parameter -Xms3G -Xmx3G
configured the Java heapspace for 4GB of RAM. We have left 1GB free in our case for the OS and any other stuff that it needs the ram for. Change this to the amount of RAM you want to allocate to the Spigot server. If your server has 16GB of RAM, you should set the parameter to occupy 14 or 15GB of RAM.
Once finished, save the file by pressing Ctrl + X and entering Y when prompted.
Make the startup script executable.
minecraft:$ chmod +x spigotstart.sh
Start your Spigot server for the first time.
minecraft:$ ./spigotstart.sh
The server will not start and instead terminate, giving the following message.
[14:14:21] [ServerMain/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
Open eula.txt
for editing.
minecraft:$ nano eula.txt
Set the value of the variable eula
to true
.
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula). #Sun Dec 26 13:29:15 UTC 2021 eula=true
Once finished, save the file by pressing Ctrl + X and entering Y when prompted.
Before starting the server, let us configure it to run it as a service in the background.
Step 6 - Configure Spigot as a service
The server needs the shell to be running all the time for it to work, which is not ideal. We need to create a service so that the server can start automatically on boot and run in the background.
Exit out of the minecraft
user.
minecraft:$ exit
Create a Spigot Service file and open it for editing.
$ sudo nano /etc/systemd/system/spigot.service
Paste the following code.
[Unit] Description=SpigotMC After=network.target [Service] Type=forking User=minecraft Group=minecraft ExecStart=/usr/bin/screen -d -m -S minecraft /home/minecraft/server/spigotstart.sh ExecStop=/usr/bin/screen -S minecraft -p 0 -X stuff "stop$(printf \\r)" WorkingDirectory=/home/minecraft/server [Install] WantedBy=multi-user.target
Once finished, save the file by pressing Ctrl + X and entering Y when prompted.
Reload the service daemon.
$ sudo systemctl daemon-reload
Enable the service.
$ sudo systemctl enable spigot
Start the Spigot service.
$ sudo systemctl start spigot
Check the service status.
$ sudo systemctl status spigot ? spigot.service - SpigotMC Loaded: loaded (/etc/systemd/system/spigot.service; disabled; vendor preset: enabled) Active: active (running) since Mon 2021-12-27 09:15:25 UTC; 6s ago Process: 32011 ExecStart=/usr/bin/screen -d -m -S minecraft /home/minecraft/server/spigotstart.sh (code=exited, sta> Main PID: 32012 (screen) Tasks: 25 (limit: 4691) Memory: 3.2G CGroup: /system.slice/spigot.service ??32012 /usr/bin/SCREEN -d -m -S minecraft /home/minecraft/server/spigotstart.sh ??32013 /bin/sh /home/minecraft/server/spigotstart.sh ??32014 java -Xms3G -Xmx3G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockEx> Dec 27 09:15:25 spigot systemd[1]: Starting SpigotMC... Dec 27 09:15:25 spigot systemd[1]: Started SpigotMC.
Step 7 - Connect to Minecraft
Now that our server is up and running, it is time to connect to Minecraft. Launch your Minecraft game.
Click on the Multiplayer button and ignore the warning for the future by checking the box, Do not show this screen again.
Click on Add Server button on the next page.
Enter your server's public IP address and name. Click Done when finished.
Your Server will now appear on the list.
Click on your server name and press the Join Server button to start the server. Your game will start soon.
You can ask your friends to join your server and play with them.
Step 8 - Customize Server Properties
You can customize your server by editing the /home/minecraft/server/server.properties
file. We will go through some of the properties below.
-
Enable command blocks: Values available are
true
andfalse
.enable-command-block=false
-
Gamemode: Values available are survival, creative, adventure, and spectator. They can also be defined by integers starting from 0 for survival, 1 for creative, 2 for adventure, and 3 for spectator.
gamemode=survival
-
Difficulty: Values available are peaceful, easy, normal, and hard. They can also be defined by integers starting from 0 for peaceful, 1 for easy, 2 for normal and 3 for hard.
difficulty=easy
-
MOTD: Stands for Message Of The Day. It is the message that is shown on the Server list page. Accepts a string value. Supports color, special characters and formatting codes. It should not be longer than 59 characters.
motd=A Minecraft Server
-
PVP: Enables the Player versus Player mode. Values available are
true
andfalse
.pvp=true
-
Server Port: Defines the port on which the Minecraft server listens to. The default value is 25565.
server-port=25565
If you change the port value to something else, you will need to enable it in the firewall; otherwise, players won't be able to connect.
-
See the Minecraft wiki for more properties.
You will need to restart your Spigot server after making any changes to these properties for them to take effect.
$ sudo systemctl restart spigot
Step 9 - Install Plugins
You can download plugins from Spigot Resources or Bukkit Plugin pages.
If you download the plugin from Spigot, the following method won't work since it has been blocked. You will have to manually download the Jar file and move it to the server. But if you are downloading from Bukkit, use the following method to download directly to your server.
Download the .jar
file of the plugin from the above pages to the /home/minecraft/server/plugins
directory.
$ sudo wget -P /home/minecraft/server/plugins/ --content-disposition <plugin url>
The flag --content-disposition
ensures the file is downloaded with the correct file name by making use of the Content-Disposition
headers.
For example, if you are downloading the WorldEdit plugin, this is how you will download it.
$ sudo wget -P /home/minecraft/server/plugins --content-disposition https://dev.bukkit.org/projects/world edit/files/latest
To reload the plugin, restart your Spigot server.
$ sudo systemctl restart spigot
Step 10 - Update Spigot
Updating Spigot will require you to repeat step 4 of this guide to grab the latest version of BuildTools.jar
file and then create a fresh spigot.jar
file. Make sure you backup the old jar files and stop the server before doing that.
Conclusion
This concludes our tutorial on installing and configuring the Spigot Minecraft server on a Ubuntu 20.04 based system. If you have any questions, post them in the comments below.