It’s actually much easier than I thought.
Simply spin up a VPS from a hosting provider of your choice, and follow the following steps. Note that I use Ubuntu as the version of Linux because that’s what I am more familiar with. If you are familiar with others, the steps should be the same.
Prepare the system
First, add the Java repository to the system.
sudo add-apt-repository ppa:linuxuprising/java
Then update your system.
sudo apt update sudo apt upgrade
Now let’s install the latest Java.
sudo apt install openjdk-17-jre
And that’s pretty much it to get your system ready to run Minecraft.
Minecraft time
To make things clean, you can create a subfolder just for Minecraft and download
mkdir minecraft cd minecraft
Now head over Minecraft Server download page to find the URL for the latest version, and copy it to the clipboard for the wget command to download it.
wget https://launcher.mojang.com/v1/objects/a16d67e5807f57fc4e550299cf20226194497dc2/server.jar
Note that this is to download version 1.17.1. The URL may differ if the version is different.
Rename the package to match the version so you don’t get confused later on.
mv server.jar minecraft_server_1.17.1.jar
Time to rock.
java -Xmx1024M -Xms1024M -jar minecraft_server.1.17.1.jar nogui
Ooops…if this is the first time you run it, you will most likely get an error saying that you have to agree on the end-user agreement. Let’s bypass it.
nano eula.txt
And replace the False word with the word “True”. Save it, get it out, and run it again.
You should be in.
Now let’s connect your Minecraft game to the new server.
Open the Port for remote access
Lastly, you will need to open the TCP port 25565 on server to allow remote connection to come in.
A few notes
First, the launch line defaults to use 1GB of RAM for the game. That’s good enough for 3 to 4 people enjoying the game. Any more, you will need to increase that number.
If your VPS only has 2GB of RAM, the server will likely crash when the number of people online reaches 5 or 6. Time to upgrade to the next tier. Then, adjust the -Xmx parameter to allow the game to use more RAM. For example,
java -Xmx4GB -Xms1024M -jar minecraft_server.1.17.1.jar nogui
Then, if you need to shut down the server for now, you may think about backing up your game data for the future. All data are stored in a folder called World, or the level name you have set up in the server.properties file. Back up that folder and restore it to another server later on when you are ready to resume the game.
Since it needs to be run continuously, it’s recommended to run it under a screen session that doesn’t close.
Simply type screen to open a new session. And then launch the Minecraft server in it.
To get out of the session, press Ctrl + A + D.
To list all available sessions, run
screen -list
To re-enter a running session,
screen -r #session
To completely close a session, type exit.