This tutorial will show you how to set up and configure your own Minecraft server on a VPS.
We will be installing SpigotMC, a highly optimized Minecraft server, written in Java, with integrated support for plugins. In the end, you will have a Minecraft server always ready for you and your friends to play on.
What We Are Going to Cover
- How to install Java runtime and Git for Ubuntu/Debian and CentOS,
- How to compile Spigot,
- Connecting to the server and verifying that everything works correctly
- An overview of some must-have plugins
- A clean Linux VPS running Ubuntu 16.04 and up, Debian, or CentOS 7
- root user access
- 1Gb of RAM memory for the Minecraft server itself, to support up to 4 players
- Add 1Gb of RAM per additional 5 players
- CentOS uses a lot of memory for itself, so plan on adding even more RAM on that operating system.
- At least 2 CPU cores (for up to 4 players). More powerful CPUs with more cores will be required in case of higher loads.
Step 1: Installing Java Runtime and Git
Once you are logged in as root, you can create a new user account that you’ll use from now on for running Spigot. The root user is not needed for running a Minecraft server.
We’ll call the new user spigotuser. On both Ubuntu / Debian and CentoOS the first step is the same:
Further instructions differ:
Setting Up Java and Git on Ubuntu / Debian
On Debian and Ubuntu, you need to add spigotuser to the sudo group, so that you can run commands as sudo:
usermod -aG sudo spigotuser
You will be immediately asked to enter a password for the new user, so provide it.
Log in as the new user:
Run the following commands to refresh apt cache and install Git, Java and wget:
sudo apt update sudo apt install -y git openjdk-8-jdk wget
Setting Up Java and Git on CentOS
On CentOS, to be able to run commands as sudo, you’ll need to add spigotuser to the wheel group:
usermod -aG wheel spigotuser
In contrast to Ubuntu, CentOS will not ask you to enter a password, so you’ll need to set it up manually with the following command:
Then, log in as the new user:
Use yum to install Java and wget:
sudo yum install -y java-1.8.0-openjdk-devel wget
You’ll need to install Git separately, because CentOS comes with an outdated version that practically won’t work. Add repository which maintains the latest Git to yum:
sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm
Then, install it:
sudo yum -y install git2u-all
Now you have all the reqired dependencies installed. Next, you’ll build Spigot.
Step 2: Building Spigot
Create a folder to house the binaries which we will soon generate:
Navigate to it:
Because of legal concerns, Spigot does not distribute binaries directly. Instead, you’ll have to download and run Build Tools, a specialized program that generates the final Spigot server binary.
Download the latest Build Tools version by running:
Before actually running Build Tools, you’ll need to configure Git so that it does not automatically convert line endings:
git config --global --unset core.autocrlf
You can now run Build Tools to get fresh server binaries for the latest available server version:
java -jar BuildTools.jar --rev latest
Instead of latest, which may be unsuitable for production use, you can also pass in a specific Minecraft version. At the time of this writing, the latest stable Spigot version was 1.13.2. If you wanted this specific version, run this command:
java -jar BuildTools.jar --rev 1.13.2
The compilation will take a long time, especially on slower machines, so be patient. You’ll need to have at least 512Mb RAM free for Build Tools to use.
When it finishes compiling, you’ll have a JAR file in the directory, called spigot-rev.jar, where rev is the version of Minecraft. For the command above, it will be spigot-1.13.2.jar.
Step 3: Starting Up the Server
You should separate compilation files from server files, so create a new directory for the server:
Copy the JAR file to the new directory:
cp spigot-1.13.2.jar ~/spigot-server/spigot.jar
Navigate to the directory:
Before running the server for the first time, you’ll need to create a file called eula.txt to signify that you agree with the Mojang Account EULA. Create it using nano:
Add the following line:
Save and close the file. You’ll now create a script that will be used for starting your Spigot Minecraft server. Create a file called start.sh:
Add the following lines:
#!/bin/sh java -Xms1G -Xmx1G -XX:+UseConcMarkSweepGC -jar spigot.jar
The command runs Spigot with 1Gb allocated (as denoted by 1G in the command). You must change this in both places to the amount of RAM you can give Spigot on your server – otherwise, it won’t run.
When you are done, save and close the file.
Make it executable:
chmod +x start.sh
Now, run Spigot server for the first time, which will generate configuration files and folders you can later customize:
Allow it some time to initialize the worlds: the Overworld, the Nether and the End.
When it says Done!, type
into the console to shut the server down. If you now run ‘ls’, you’ll see that Spigot has generated its data structures and written them to the disk:
Spigot uses .yml and .json files to store its internal configuration. The folders are used for storing the following:
- logs – Spigot runtime logs
- plugins – initially empty. This is the folder where you’ll place compatible plugins
- world – Minecraft world Overworld
- world_nether – Minecraft world Nether
- world_the_end – Minecraft world End
server.properties configures gameplay-related settings. Here is what its default version looks like:
A complete list of parameters can be found here, along with their explanations. These are the most important ones:
- gamemode – sets the game mode: 0 is survival, 1 is hardcore, and 2 is creative mode
- spawn-monsters – true by default; controls whether monsters spawn
- pvp – true by default; enables Player vs Player fights
- max-players – sets the maximum numbers of players who can play on your server at the same time. Set to 20 by default; you should edit this according to system resources allocated to Spigot
- server-port – the port of the server. You should leave the default value (25565)
- spawn-npcs – true by default; controls whether villagers spawn
- allow-flight – set this to true to allow players to fly
- level-name – set to world, which is the default world Spigot automatically generates. It is located in a folder with the same name. You can put your custom world in a folder and enter its name here to play on it
- spawn-animals – true by default; controls whether animals spawn
- white-list – false by default; set this to true to enforce the whitelist. Allowed UUIDs (usernames) can be set in the file white-list.txt, one per line
- generate-structures – true by default; controls whether the world generator spawns structures in biomes
- online-mode – if true, only paid Minecraft accounts can connect to the server
- motd – the text that will be shown underneath the server name in Minecraft. Supports Unicode characters, but they must first be escaped
You can edit server.properties with the following command:
When you are done, start the server again:
Keeping the Server Turned On
When you close you current SSH connection, your server will shut down. To prevent this, you can run it in a separate terminal using screen. Create a new file, called start-screen.sh, for editing:
Add the following line:
screen -S "mc-server" -U -m -d sh start.sh
Save and close the file.
This command starts a screen with the name mc-server in detached mode, which means that it will run in the background on the VPS. When it launches, it runs the command sh start.sh, which in turn starts the server. This way, even after you close your SSH connection, your Minecraft server will always be available for you and your friends to play on.
Step 4: Connecting to Your Server
When the server loads, open Minecraft on your local machine. Click on Multiplayer, then press on Add Server. Enter a name of your choice and for the server address, enter :. You can omit the part if you left the port setting intact (25565).
Press on Done and double click on your server in the list.
Wait a while for it to connect, and then you and your friends will be able to play on your own Minecraft server!
If you get the following error when connecting to your server:
that means that you have tried to connect with online-mode set to true in server.properties. Set it to false and try again.
Step 5: Learning About Spigot Plugins
Right now, your server will offer a vanilla experience. You can install plugins from the Spigot’s website by downloading the JAR files and then uploading them into the plugins directory. The easiest way to upload files to your server is via FTP, but setting that up is out of scope of this tutorial.
The server will load plugins on every start, and report any errors (most likely arising from version incompatibilities) immediately. When you add new plugins, restart your Minecraft server by joining it from the game and issuing the /restart command.
Here are some must-have plugins that will greatly enhance your player’s experience:
- Vault – a plugin that all others depend on. It greatly simplifies plugin development
- EssentialsX – this plugin adds over 100 convenience commands that your players will expect to find
- WorldEdit – an in-game world editor. It allows for massive & easy block manipulation
- WorldGuard – depends on WorldEdit. It allows you to define in-game access rules, for example to prevent players from griefing your property
- LuckPerms – every server should have a permissions plugin, and LuckPerms is fast, reliable and maintained. It also offers a web editor, and is very easy to use
Dusko Savic is a technical writer and Flutter developer.