Header image

Minecraft server on debian, the full explanation…

Kevin Goos
5 min readDec 19, 2021

After a question from my friend, I decided to setup a Minecraft server. But what look to be an easy task, took me almost 2 days to do. The problem being, that documentation is scattered all over the internet. So my intent with this article is to gather all the information I found, and guide you to a decent setup Minecraft instance.

1. Instal debian

While installation of a new Linux instance is easy for me. It mostly depends on the underlying system that is being used. I use Proxmox as virtualisation environment so I just created an LXC container running Debian buster.

Some default applications I install (but you can use whatever you prefer):

apt install vim, sudo -y

2. Minecraft server itself

For this step, my friend prepared the full setup of the Minecraft server itself (using Fabric).

The first question you need to ask yourself is what version of Minecraft do you want to use, 1.18.1, … And after that, will it be vanilla? Or do we want to use a modloader like Fabric, Forge, … I think there is enough documentation easily accessible depending on which version you want to use.

3. Setup users

Both for the FTP and the service later in the article we need a user, so first we setup the user profiles.

This can be simple done with the following command:

adduser username

And for the service user we add some extra parameters (-s /sbin/nologin will block the user from logging in, and -r will make it a system user, -U will create a group with the same name as the user):

useradd -r -s /sbin/nologin -U minecraft

So lastly we want to also add the other user to the new group:

usermod -a -G minecraft username

3. Uploading files to the server (optional)

SCP for uploading the files to the server would work perfect, but because my friend is not really a command line guru we picked the option of using an FTP client/server setup. For the client you can pick whatever software you want, but for the server we used VSFTP.

First I started by creating the folder where the server while exists.

mkdir /opt/minecraft

Then, installation is done by the following command.

apt-get install vsftpd -y

And the last step is setting up the configuration file. The best is first to backup the default file, so that you can look back in the future.

mv /etc/vsftpd.conf /etc/vsftpd.conf.bk
vim /etc/vsftpd.conf

This is the config file I ended up with:

listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
allow_writeable_chroot=YES
pam_service_name=vsftpd
user_sub_token=$USER
local_root=/opt/minecraft
userlist_enable=YES
userlist_file=/etc/vsftpd.userlist
userlist_deny=NO
local_umask=011

We also setup the file configured in the above config file:

vim /etc/vsftpd.userlist

This will contain all the users that you want to give access to the FTP server.

After that a quick restart of the service will get everything up in running order:

sudo service vsftpd restart

4. Testing the server

After you upload you can try starting the server, normally everything should run.

First switch to the minecraft user:

java -jar fabric-server.jar

Depending how you named you’re jarfile this will change a bit. And also you can setup the right amounts of memory you want to use.

java -Xms4G -Xmx8G -jar fabric-server.jar

And if the server startup correctly you can also connect to it in you’re local network.

4. Port forward (if friends want access over the internet)

So for giving other people access to you’re server you need to open a port on you’re router, the default port is 25565 for minecraft (unless you changed the port inside server.properties file). Forwarding this on you’re router or ISP modem depends on which device you have. So a quick search on google will solve this for you.

5. Service? (optional but preferred)

In debian you can create a service to keep the server running, after a crash or even after reboot. For this we need to add another config file.

vim /etc/systemd/system/minecraft.service

And the config file contains the following configuration:

[Unit]
Description=Teamsepak Minecraft Server
After=network.target
[Service]
ExecStart=java -Xms4G -Xmx15G -jar fabric-server.jar
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft/fabric-multidc-1.18.1/TimeoutStartSec=0
Restart=always
RestartSec=30
[Install]
WantedBy=default.target

After saving this config file, we need to reload and start the service:

systemctl daemon-reload
systemctl start minecraft.service

Now it should be up in running and to check this you can use the following command:

systemctl status minecraft.service

The ouput should like this, showing the active (running):

Status of the service

Also if you want to follow the service logs you can use the following command to output all the log lines to the console.

journalctl -f

5a. DNS for first Minecraft server (optional)

The last step is giving you’re friends easier access. Always typing in the ip of you’re ISP is annoying so that is why there exists domain names. For a small 6 euro / month you get access to a domain name (and there are also free options). I use OVH as my domain vendor, so all the setup steps will be from the OVH domain manager UI.

So pointing you’re domain name to you’re ISP is easy, just create an A record with the IP.

Setup A record

5b. DNS, you’re second Minecraft server (optional)

But what if this is you’re second or third server on a different port? Of course you can just add the port at the end of the URL (minecraft.mydomain.be:25566). But then you’re user need to remember which port the server was running on.

This is why Minecraft support SRV record, they will tell you’re Minecraft client on which port the user need to connect. The setup is also not that difficult, you just need to know what you need to input where.

First you create an A record again

Create an A record

And now you create the SRV record:

Create an SRV record

Here you see:

  • Sub-domain:
    _minecraft._tcp.minecraft2.mydomain.be
    - _minecraft = name of the service
    - _tcp = protocol
    - minecraft2 = same subdomain as the A record created
  • Priority: This decides which records comes first.
  • Weight: After priority we look at weight for who comes first.
  • Target: this is the same as the A record.

Disclaimer

So after this you normally have a running server which people can easily access, from everywhere. I am also not an expert at these topics so there are probably things that can be optimised. And if there are you can always let me know and maybe I will adapt both my setup and this article. But this is what I currently figured out, and the most import thing is that it works for me for now.

--

--

Kevin Goos

Currently I am freelance .NET developer. After work I also love to put some time in managing my own servers and services.