Root-Server Tutorial

ROOT-SERVER TUTORIAL

Setup of a Minecraft server based on Purpur

Learn how to set up a Minecraft server with auto-update and auto-start based on Purpur.

Author:

Mawoka

Last updated:

25/11/2021

Introduction

This tutorial describes how to set up a Minecraft server based on Purpur

The most important requirement for implementation is a basic understanding of the Unix command line. All examples were tested on a current Debian/Ubuntu (November 2021) and can be easily adapted to other distributions.

The tutorial uses the example hostname v11111111.quicksrv.de. This hostname needs to be replaced by the name of your own server when you perform the workflow described in this tutorial. Placeholders are written like this: <TYPE OF PLACEHOLDER>, e.g. <USER> should be replaced with your linux-username.

Requirements

  • The server should be economical,
  • have sufficient CPU power, and
  • it should at least have 8GB of ram.

The hard disk capacity, on the other hand, is not relevant.

Step 1 - Ordering the VPS

At the time of the creation of this tutorial (October 2021), the recommended product to be used as Minecraft-server is VPS 1000 G10. Existing customers can add the product easily and quickly.

Step 2 - Basic configuration of the server

After provisioning of the server and the first login with the username root and the password sent by email, the first step is to update the basic configuration of the server.

  1. Change the root password by means of passwd.
  2. Import the current security updates with apt-get update && apt-get upgrade -y.
  3. Create a user (adduser) and give him root permissions (usermod -aG sudo <USER>).
  4. It is recommended to set up an SSH key at this point and to disallow password login for the root user. These procedures are not part of this tutorial and as the later functionality requires root capability, the setup of an unprivileged user is omitted at this point.

Step 3 - Install Java

## install the necessary dependencies
sudo apt-get -q update
sudo apt-get -yq install gnupg curl 

## add Azul's public key
sudo apt-key adv \
  --keyserver hkp://keyserver.ubuntu.com:80 \
  --recv-keys 0xB1998361219BD9C9

## download and install the package that adds 
## the Azul APT repository to the list of sources 
curl -O https://cdn.azul.com/zulu/bin/zulu-repo_1.0.0-3_all.deb

## install the package
sudo apt-get install ./zulu-repo_1.0.0-3_all.deb

## update the package sources
sudo apt-get update
sudo apt install zulu17-jdk-headless screen wget nano

Step 4 - Create the scripts

Start by creating a new folder (mkdir minecraft-server) and cd into it: cd minecraft-server Create the file start.sh by entering nano start.sh and paste the following content:

##!/bin/sh
cd /home/<USER>/minecraft-server/
wget -q -O purpur.jar https://api.pl3x.net/v2/purpur/1.17.1/latest/download
sleep 20s
/usr/bin/screen -dmS minecraft-server /usr/bin/java -Xms1G -Xmx5700M -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 purpur.jar nogui
echo "Successfully started"

If you want to use another Minecraft version, replace 1.17.1 with your Minecraft version.

Now, make the file executable by entering chmod +x start.sh and start it: ./start.sh. It should download some stuff and it should crash. That's because you have to agree to the eula in the eula.txt. Do this by opening the file (nano eula.txt) and changing false to true:

- eula=false
+ eula=true

Now, start the start.sh again (./start.sh). You may have noticed that there is no output to the console since it is running in the background. You can "attach" to it by running screen -r minecraft-server or just screen -r. There, you have the full console. To access the console without stopping the server, press STRG+a and after that STRG+d.

Step 5 - Auto-start

If you want your Minecraft server to start automatically with your server, open the crontab (crontab -e) and add the following line: @reboot sleep 10s && ./home/<USER>/minecraft-server/start.sh.

Conclusion

You are done! Connect to your server now with the following address: v11111111.quicksrv.de:25565.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributor's Certificate of Origin

By making a contribution to this project, I certify that:

  1. The contribution was created in whole or in part by me and I have the right to submit it under the license indicated in the file; or

  2. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same license (unless I am permitted to submit under a different license), as indicated in the file; or

  3. The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

  4. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the license(s) involved.

Published 25/11/2021 by Mawoka

Submit your tutorial

Get 60€ netcup vouchers for every published tutorial.