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.
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:
adduser spigotuser
Further instructions differ:
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:
su spigotuser
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
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:
passwd spigotuser
Then, log in as the new user:
su spigotuser
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.
Create a folder to house the binaries which we will soon generate:
mkdir ~/spigot-binaries
Navigate to it:
cd ~/spigot-binaries
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:
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
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.
You should separate compilation files from server files, so create a new directory for the server:
mkdir ~/spigot-server
Copy the JAR file to the new directory:
cp spigot-1.13.2.jar ~/spigot-server/spigot.jar
Navigate to the directory:
cd ~/spigot-server
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:
nano eula.txt
Add the following line:
eula=true
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:
nano 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:
./start.sh
Allow it some time to initialize the worlds: the Overworld, the Nether and the End.
When it says Done!, type
stop
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:
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:
You can edit server.properties with the following command:
nano server.properties
When you are done, start the server again:
./start.sh
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:
nano start-screen.sh
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.
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.
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:
Dusko Savic is a technical writer and Flutter developer.
The post How to Set Up a Minecraft Server on Your VPS appeared first on Low End Box.
One of the most critical gaps in traditional Large Language Models (LLMs) is that they…
Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…
What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…
Wouldn’t it be wonderful to wake up one day with a desire to explore AI…
Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…
Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…