If you havn't already done so, download the program "PuTTY".
Connect to your root server or VPS/vServer via SSH using PuTTY. To do this, open PuTTY and enter the domain or IP address of your server in the text box named "Host Name (or IP address)". Then click the "OK" button below.
Update your package lists with the command apt update
Now install any available updates of the packages already installed on your server using the command apt upgrade -y
Next, install the packages needed for future installations in this tutorial by executing the following command: apt install gnupg curl dirmngr nano unzip -y
Add the repository needed to install Java: For Debian:
Use the command apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A to add the key needed for the Java repository.
Add the repository by executing the command echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu focal main" | tee /etc/apt/sources.list.d/java.list
Install the package for managing repositories using the following command: apt install software-properties-common -y
Add the repository by executing the command add-apt-repository ppa:linuxuprising/java.
Now update your package lists again with the command apt update
Install Java with the following command: apt install oracle-java17-installer -y
Accept the license terms by selecting the "OK" button using the Tab key, confirming the selection with Enter, selecting the "Yes" button using the arrow keys, and then pressing Enter again.
Install the software "screen". You'll need this to let the Minecraft server run in the background later, so you can close the PuTTY window without causing the Minecraft server to stop. Use the following command for the installation: apt install screen -y
Now add a user who will run the Minecraft Server on your Linux server. Use the following command: adduser --disabled-login minecraft In this example the user is called "minecraft". You can use a different name, but make sure to always use your own chosen user name instead of "minecraft" when you follow the next steps of this tutorial (e.g. "mcserver").
You can skip all further information such as the name, telephone number, etc. by pressing enter as well.
Now use the command su minecraft to switch to your Minecraft user.
Go to the home directory of this user by executing the command cd The home directory is named exactly like the user himself and therefore the path is "/home/minecraft".
Then use the command wget https://download.getbukkit.org/spigot/spigot-1.17.1.jar to download the latest version of Spigot. If you want to use Craftbukkit, the command is wget https://download.getbukkit.org/craftbukkit/craftbukkit-1.17.1.jar
After the download is completed, you should see the downloaded JAR file using the command ls
Next, create a start and a stop script. These two scripts let you start and stop your Minecraft server later. To create the start script named "start.sh", use the command nano start.sh Now the nano text editor opens. Here you need to enter the following command: screen -AmdS minecraft java -Xms4096M -Xmx4096M -jar /home/minecraft/spigot-1.17.1.jar nogui Make sure you enter the correct filename of your previously downloaded JAR file. Instead of "4096", you can specify the amount of RAM in MB that you want to reserve for your Minecraft server. Important: Keep enough memory for the system and other software running on your Linux server.
Now save the start script by pressing CTRL + X, then hit the "Y" key and press enter.
Now create the stop script as well by executing the command nano stop.sh. Within the nano editor you need to write the following command into your script: screen -r minecraft -X quit Save the stop script just like the start script by pressing CTRL + X, then hit the "Y" key and press enter.
After that you have to assign execution permissions for these two scripts. You do that with the following command: chmod +x start.sh stop.sh
In order to be able to start the Minecraft server, you must first accept the license terms. To do this, execute the command echo "eula = true" > eula.txt This creates a file which indicates that you accepted these license terms.
Then run the start script to start your Minecraft server. Use the command ./start.sh
To get into the Minecraft server console, you need to open the screen background process. To do this, execute the command screen -r minecraft Under Debian 9, however, you must execute the command script /dev/null before using the screen command. If you are logged in as the user "root", you must first switch to the Minecraft user by executing the command su minecraft To exit the Minecraft server console, press CTRL + A and then press the "D" key.
Your Minecraft server is now ready to use. You can start and stop it at any time. Just log in as the Minecraft user by executing the command su minecraft go to the Minecraft server directory using the command cd /home/minecraft and execute the start or stop script (./start.sh or ./stop.sh).