Installing Java
The first thing you need to do is ensure you have installed the relevant Java JDK version for your desired Minecraft version. The latest release of Minecraft (1.20.1) currently uses Java 17 so that is the version we will be installing in this tutorial. Ubuntu uses theAPT package manager, it’s generally considered a good idea to run the following commands before trying to install an application for the first time.
version-number to determine if you would like to install Java 8, Java 11, Java 17 or Java 21.
:::
Creating the Minecraft server
We are nearing the end of this guide, only a few more things to do! Before we download anything, we should make a directory to put our server in. You can do this by typing the following commands.--content-disposition we’re preventing the downloaded file being an extension-less file called download.
To confirm the file has downloaded correctly you can use the ls -al command to display the contents of the minecraft-server-folder.
Done in (seconds) you can press shift + c to end the session or type stop like a normal server.
So now technically everything is setup and ready - If your newly created VPS was sitting in your house you would be able to play right now… but it’s not - so we need to open the 25565 port to the internet.
Making it accessible over the internet (Port Forwarding)
While we’re still connected via SSH it will save time later for us to configure the servers local firewall now. :::info This tutorial uses Ubuntu and UFW. If you chose another another distro at the start of this guide you will most likely have a different wrapper, if this is the case you will need to consult the docs for how best to open ports 25565 for TCP and UDP traffic. ::: To open TCP and UDP traffic within Ubuntu we need to use the following commands.Optional Configuration
The above steps will get you up and running with the basics, but some settings can be adjusted further to make life easier for yourself as an admin.Adjusting RAM Allocation
We go over adjusting the RAM allocation in more depth here.Installing ‘Screen’
Screen is an application that allows for you to run your server in the background even after you close your SSH session. To install screen run the following command.CTRL + A + D. You should now be able to close the command prompt window without the server crashing. If you need to return to your screen windows you can use the command screen -r.