how to host a minecraft server on debian

Hosting A Minecraft Server On Debian: The Ultimate Guide

Minecraft is one of the games where you can create your own server, play with your friends or even create a new community with players around the world. But before doing this, you need to set up your server, and it’s not necessarily straightforward when you do it for the first time. Let me quickly guide you on how to do this.

Installing a Minecraft Server on Linux requires some prerequisites like the Java runtime environment and the server program. A few important steps are then recommended to do it the right way, like creating a script, configuring the firewall and creating regular backups.

I will show you everything in this article, starting from the beginning with the system installation and configuration, and giving you different tips you won’t find elsewhere.

Linux doesn’t have to be intimidating. With my e-book, Master Linux Commands, you’ll uncover the secrets of the terminal in a fun, step-by-step journey. From basics to scripts, get ready to level up your Linux skills. Oh, and did I mention the handy cheat sheet you get as a bonus?

Prerequisites to install a Minecraft Server on Debian

Before installing your Minecraft Server on Debian, you need to have a Debian system installed and up-to-date, with a few important prerequisites: sudo access, Java and Git installed, firewall configured. Screen is also recommended, and you’ll need to choose between Spigot and the official Minecraft server.

Let me explain all of this.

Debian system configuration

I’m testing this on a minimal edition of Debian (no GUI or useless apps). You might already have some of the things listed below installed, but I want to be thorough just in case.

Sudo

Sudo is not installed by default on Debian, and the default user doesn’t have administrator privileges.

You’ll need these permissions for most commands in this section, so I recommend starting by installing it.

Alternatively, you can switch to the administrator account for the first steps, but I’m familiar with sudo and prefer doing it this way.

From your user account, switch temporarily to the administrator account with:
su -
Then install the sudo package with:
sudo apt install sudo

The next step is to allow the normal user to run commands with sudo. There are several ways to do this, I choose to use visudo to edit the permissions:
visudo

Find the line with the root privilege, and duplicate it for the default user.
It should look like:
<user> ALL=(ALL:ALL) ALL

Save the file and exit (CTRL+X).
You can now quit the administrator session and get back to the normal user terminal with:
exit

If you’re new to the Linux command line, this article will give you the most important Linux commands to know, plus a free downloadable cheat sheet to keep handy.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

System updates

Just in case, make sure your system is up-to-date. It’s also a great way to test if sudo is working without using the root account.

Type these commands:
sudo apt update
sudo apt upgrade

A reboot is recommended if a lot of packages are updated with these commands. You can then move to the next step.

Java runtime

Now that the Debian system is up-to-date, we can start to install the requirements for Minecraft. Minecraft uses Java, so we need to install the runtime before anything else.

Warning: Most tutorials online will tell you to install the “default-jre” package for this, but it’s often bad advice.
On my test server, “default-jre” will install Java 11, while version 17 is required to run the latest Minecraft server version, so it won’t work.

You can check the current requirements for Spigot here. At the time of writing, it’s explicitly mentioned that Minecraft 1.18 requires Java 17 or later. So make sure you are installing a supported version.

Anyway, you can use APT to install Java, with this command:
sudo apt install openjdk-17-jre

Just change the version number in this command if the Minecraft server requires another version at the time you are following this tutorial.

Once done, you can check that Java is properly installed with:
java -version

Install screen and git

Git is required to install Spigot (I will explain what it is later), and screen is not mandatory, but it’s a nice tool to keep the server running all the time (I’ll explain how to use it at the end of this article).

So, I recommend installing these two packages right now if you don’t have them yet:
sudo apt install screen git

Firewall check

If you have a firewall enabled on your server, you probably need to open a port for Minecraft.

A Minecraft server uses port 25565 by default (it can be changed in the server configuration), so make sure this port is open for your user’s IP on this server.
If you use UFW, it could be something like:
sudo ufw allow 25565

I won’t go into more detail for this step, as the configuration will be different for each case, but don’t forget to do it if you have a firewall enabled. You may also need to configure some kind of port forwarding or DMZ if you want to open your server to other Internet players.

Difference between the official Minecraft server and Spigot

The game editor (Mojang) provides server software for Minecraft for free (link). It can be used to play with friends, exactly like a Solo game. But this server software is limited, we also call it “Vanilla” as it’s the original game.

Spigot, on the other hand, is a modified version of the official Minecraft server software, allowing more configuration options and plugin installation. This means that the gameplay can be modified to meet your specific needs.

For example, with Spigot you can:

  • Give different permissions to different users (especially useful if your server is open to random players).
  • Add convenient commands (teleportation to your base or to the server spawn for example).
  • Create additional worlds (like one for farming, so you keep the server spawn clean).
  • Add tons of new features (mini-games, scoreboards, economy system, new recipes, etc.).

I never use the official server software, and always install the Spigot alternative. You’ll get more freedom for your server configuration, and it will be easier to add new features later, even if you don’t see the point at the moment.

The end of this tutorial will show you how to install Spigot on your Debian server, but you can follow the same steps with the official server if you want (just skip the next part and replace the Java file name in the following ones).

Download and build your Minecraft server

With Spigot, there is an additional step, where you need to download “BuildTools”, a Java program that will download, compile and build the files to generate the final Minecraft server file.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

Download the latest version

First, download the latest BuildTools file from their Jenkins server, here is the direct link to the latest version.

Click on the file name to download it on your computer, and then transfer it to your server (via SFTP, for example).

If, like me, you are following this tutorial via SSH, you can copy the file URL and download it directly on your Debian server with:
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar

Build the server files

We’ll then run this file with Java to start the building process:

  • I recommend creating a specific subfolder for it or at least doing it in your “Downloads” folder or similar.
    The compilation will create many subfolders and temporary files, so it’s better to use a separate folder for this.
  • For example:
    mkdir buildtools
    mv BuildTools.jar buildtools
    cd buildtools

    This will create a temporary folder named “buildtools” with everything in it, so you can remove it when you are done with this.
  • Then, simply start the process with:
    java -jar BuildTools.jar
    By default, it will create the server file for the latest stable version, but you can specify a different version with the option –rev, for example:
    java -jar BuildTools.jar --rev 1.18

From there, the program will do everything for you, it might take a while depending on your server and Internet connection. Once everything is completed, you’ll get a message looking like this:

The only file we need after that is spigot-1.19.2.jar, which we’ll use in the next steps.

Start your Minecraft server

Whether you chose to compile Spigot or to use the official Minecraft server, we can now start the Minecraft server for the first time.

Create the file tree

As for the Spigot compilation, I recommend creating a specific folder for your Minecraft server.
We’ll use only one file to run it, but it will create many subfolders and files in the same folder.
So, please start by creating a subfolder for it, and move your server file to this folder.

For example:
mkdir minecraft_server
cp spigot-1.19.2.jar minecraft_server
cd minecraft_server

Edit these commands to use a different folder name if you like, and the correct file version or name for your server file.

Start the server for the first time

For the first start, you can simply use this command format:
java -jar <server-file>
So, in my example, it’s:
java -jar spigot-1.19.2.jar

It won’t work, but it’s normal. You’ll get an error like this:

You are required to read and accept the EULA before using this software.
To accept it, you need to edit the eula.txt file:

  • Open the file with:
    nano eula.txt
  • There is only one line in it. Change the value from “false” to “true”.
  • Save the file and exit (CTRL+O, CTRL+X).

You can now start the server again, and this time it should work and load everything until the “Done!” statement in the console.

Create a script to start your server

At this point, I recommend stopping the server and creating a script with additional parameters:

  • In the server console, type “stop” to stop the server.
    Wait a few seconds until you get access to the normal Debian terminal.
  • Create a new file with Nano:
    nano start.sh
  • Paste these lines in it:
    #!/bin/sh
    java -Xms2G -Xmx2G -XX:+UseG1GC -jar spigot-1.19.2.jar nogui

    Edit this line depending on your server filename and the amount of memory you want to allocate to your Minecraft server.
    In this example, I’m using 2 GB, which is the minimum. If you have more RAM, feel free to set a higher value here.
  • Save and exit.
  • Add the execution permission to this file:
    chmod +x start.sh

You can now start your server again with the command:
./start.sh

Feel free to add more lines to this script if you want.
For example, I generally add a loop in it, so the server will automatically restart when it crashes.
Or you can add a backup command when it’s stopped, a notification to the administrator, or things like that.

Test your Minecraft server

You should now be able to access your server for the first time.
Keep it running in your SSH session, and start the Minecraft client on your computer.

  • Make sure to use the same version on your client as your server.
    For example, when I’m testing this, the latest version on the client is 1.19.3, but my server is running on 1.19.2. I need to create a different profile for the client to use 1.19.2 instead.
  • Then go to “Multiplayer” and add a new server with the Debian server IP address:

    Don’t know the IP address? Read this article.
  • Your server will appear in the server list, double-click on it to connect to it.

That’s it! It’s working, you’ll be connected, and can see new events in your SSH console, mentioning that you are now connected:

From there, you can already start to play, and invite friends or family members to join your server.
But I recommend checking the next few tips before that.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

Additional tips for your Minecraft server

Congrats, you have done the hard part, and your Minecraft server is now working!
Here are a few additional tips to go further.

Use screen

You’ll quickly notice that if you close the SSH connection to your Debian server, the Minecraft server will crash. It’s running in your session, and it will stop if you lose the connection, exit the SSH client or reboot your computer.

To avoid this, we need to run the Minecraft server from the Debian server itself. And to have a way to regain access to the console, the easiest way is to use the “screen” program I asked you to install early on.

  • Stop the Minecraft server for now:
    stop
  • From the Debian terminal, start a new screen with:
    screen -S spigot
    The parameter is the screen name, you can use whatever you want (in fact you won’t need it if you use only one screen).
  • Then start your Minecraft server:
    ./start.sh
  • You can now exit the screen with CTRL+A and CTRL+D.
    You won’t see the console anymore, but if you close your SSH connection, the script and the screen will continue running on the server.

If you want to return to the Minecraft server console, just use:
screen -r

Install new plugins

I told you that the advantage of using Spigot over the official Minecraft server is the possibility to install new plugins. You can download them from the official website (here).

Each plugin comes as a Java file (.jar) and can be added to your server by uploading the JAR file to the “plugins/” subfolder in your server folder.
It will be installed on the next reboot of your Minecraft server, and will generally create a new subfolder under “plugins/” with the plugin configuration files.

Check the presentation page of each plugin to learn more about its configuration options.

Thousands of plugins are available for Spigot, so it can be overwhelming to find the ones you should use on your server. Hopefully, some specialized websites will guide you. For example, you can find here a list of the best plugins for your Spigot server, with a brief introduction and the links to download them.

Create regular backups

Last but not least, don’t forget to create a full backup of your server folder regularly.

I ran a Minecraft server for years, and I can tell you that it will crash from time-to-time, without necessarily saving the last changes, and sometimes even creating corrupted files or areas in the game. Having a backup, at least daily, will save your life.

The best way to create a backup of your Minecraft server is to do a full backup of the Minecraft folder when the server is stopped. That’s why I generally do this in the “start.sh” script, and schedule a reboot at least once a day.

If you can send the backup files to another server (a NAS, for example), it’s even better. You can find my tips to back up files from a Raspberry Pi here. You can follow the same things on any Linux server.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

If you are looking for exclusive tutorials, I post a new course each month, available for premium members only. Join the community to get access to all of them right now!

Additional Resources

Overwhelmed with Linux commands?
My e-book, “Master Linux Commands”, is your essential guide to mastering the terminal. Get practical tips, real-world examples, and a bonus cheat sheet to keep by your side.
Grab your copy now.

VIP Community
If you just want to hang out with me and other Linux fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Python is a great language to get started with programming on any Linux computer.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now.

Similar Posts