from web site
The Tech Education Fund was selected by the author to receive a donation under the Write for DOnations program.
Introduction
Minecraft is a popular sandbox video game. Originally released in 2009, it allows players to build, explore, craft, and survive in a block 3D generated world. It was the second-best-selling videogame of all time as of late 2019. This tutorial will show how to create a Minecraft server that you and your friend can use. You will install the required software packages to run Minecraft and configure the server to run. Finally, you will deploy the game.
Alternately there is DigitalOcean’s One Click Minecraft: Java Edition Server.
This tutorial uses Java Minecraft. This tutorial will not work if your Minecraft version was purchased through the Microsoft App Store. Most Minecraft versions that are purchased on gaming consoles (e.g., the PlayStation 4, Xbox One, Nintendo Switch) also come with the Microsoft version. These consoles will not connect to the server that was built in this tutorial. You can obtain the Java version of Minecraft here.
Prerequisites
You will need the following items to follow this guide:
- A server with Ubuntu 20.04 installed. To initialize your server, follow this guide. Minecraft can be resource-intensive, so keep that in mind when selecting your server size. If you are using DigitalOcean and need more resources, you can always resize your Droplet to add more CPUs and RAM.
- Minecraft Java Edition installed locally on a Mac, Windows, or Linux computer.
Step 1 - Install the necessary software packages and configure the firewall
Once you have your server up and running, it's time to install Java. Java is required to run Minecraft.
Update the package index to the APT Package Manager:
sudo apt upgrade Next, install OpenJDK 16 of Java, specifically, the headless JRE. This is a minimal Java version that does not support GUI applications. This makes it ideal for running Java applications on a server:
sudo apt install openjdk-16-jre-headless You also need to use a software called screen to create detachable server sessions. screen allows you to create a terminal session and detach from it, leaving the process started on it running. This is important as if you start your server and then close the terminal, it will kill the session and terminate your server. Install screen now
sudo apat install screen
Now that you have the packages installed we need to enable the firewall to allow traffic to come in to our Minecraft server. The initial server setup you did allowed traffic to come in via SSH. You now need to allow traffic to be sent via port 25565, which is the default port Minecraft uses for connections. The following command will add the firewall rule.
sudo ufw allow 25565
Now that you have Java installed and your firewall properly configured, you will download the Minecraft server from the Minecraft website.
Step 2 - Downloading the Latest Version of Minecraft
Now you need to download the current version of the Minecraft server. You can do this by navigating to Minecraft's Website and copying the link that says Download minecraft_server.X.X.X.jar, where the X's are the latest version of the server.
To download the server, you can use wget or the copied link.
wget https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar
If you intend to upgrade your Minecraft server, or if you want to run different versions of Minecraft, rename the downloaded server.jar to minecraft_server_1.15.2.jar, matching the highlighted version numbers to whatever version you just downloaded:
mv server.jar minecraft_server_1.15.2.jar
You can find older versions archived at mcversions.net if you wish to download Minecraft. This tutorial will only cover the latest version. Now that you have your download let's start configuring your Minecraft server.
Step 3 - Configuring and Running the Minecraft Server
Now that you have the Minecraft jar downloaded, you are ready to run it.
Start a screen session by running this screen command:
screen
Once you have read the banner that has appeared, press the SPACE bar. This will open a terminal session, just as usual. This session is now detached, which means you can start a new command here and let it run.
Now you can perform your initial configuration. Don't be alarmed if the next command throws an Error. Minecraft designed its installation so that users must agree to the company's licensing agreements. You will do this next:
1. java -Xms1024M -Xmx1024M -jar minecraft_server_1.15.2.jar nogui
Before examining this command's output, let's take a closer look at all these command-line arguments, which are tuning your server:
- Xms1024M This will allow the server to be started with either 1024MB or 1GB RAM. This limit can be increased if you need more RAM. You have two options: M for megabytes andG for gigabytes. For example, Xms2G would start the server with two gigabytes worth of RAM.
- Xmx1024M - This configures the server to use, at most, 1024M of RAM. This limit can be increased if your server needs to run at a larger scale, allow more players, or if your server is slow.
- jar – This flag specifies which server's jar file to run.
- nogui: This tells a server not to launch any GUI since it is a server.
This command, which normally starts your web server, will return the following error when it is run for the first time:
These errors were caused by the server not finding two files necessary for execution: the EULA (End User License Agreement), located in eula.txt and the configuration fileserver.properties. Fortunately, since the server was unable to find these files, it created them in your current working directory.
First, open the eula.txt file in nano or another text editor.
nano eula.txt
You will find a link in this file to the Minecraft EULA. Copy the URL.
Open the URL in your web browser and read the agreement. Next, return to your text editor. Find the last line of eula.txt. You will need to change eula=false from eula=true. Save and close the file.
Now that you've accepted the EULA, it is time to configure the server to your specifications.
The newly created server.properties.txt file can be found in your current work directory. This file contains all of the configuration options for your Minecraft server. On the Official Minecraft Wiki, you can find a detailed listing of all server properties. You will modify this file with your preferred settings before starting your server. This tutorial will focus on the most important properties.
nano server.properties
Your file will appear like this:
Let's have a closer look at some the most important properties included in this list.
- difficulty (default easy) - This sets the difficulty of the game, such as how much damage is dealt and how the elements affect your player. There are four choices: easy, normal and hard.
- Gamemode (default survival) – This determines the game mode. There are three options: survival, creative, adventure, and spectator.
- level-name (default world) - This sets the name of your server that will appear in the client. Characters such a apostrophe will need to be escaped using a backslash.
- motd (default A Minecraft Server) - The message that is displayed in the server list of the Minecraft client.
- pvp (default true) - Enables Player versus Player combat. If true, players can engage in combat with each other and cause damage.
After you have chosen the options you desire, save and close your file.
Now that you have changed EULA to true and configured your settings, you can successfully start your server.
Let's start our server with 1024M RAM, just like last time. Only now, let's also grant Minecraft the ability to use up to 4G of RAM if it needs it. This number can be adjusted to meet your server's limitations or user's needs.
1. java -Xms1024M -Xmx4G -jar minecraft_server_1.15.2.jar nogui
Give the initialization a few moments. Soon your new Minecraft server will start producing an output similar to this:
After the server is up, you will see this output:
Now your server is running and you have been redirected to the server administrator control panel. Now type help:
Help
An output like this will appear:
From this terminal you can execute administrator commands and control your Minecraft server. Let's now use screen to continue the operation of your server even after you log off. Next, you can connect to Minecraft and start a new Minecraft server.
Step 4 - Keeping the Server Running
Now that you have your server up, you want it to remain running even after you disconnect from your SSH session. Screen can be detached by pressing Ctrl+A + D. You'll then be back in your original shell.
Run this command to see all of your screen sessions:
screen -list A screen output will be generated with the session ID. This is what you need to resume your session.
To resume your session, pass the -r flag to the screen command and then enter your session ID:
screen –r 26653 Be sure to detach the session from your server with Ctrl+A + D before you log out.
Step 5 - Connecting to the Minecraft Server from the Minecraft Client
Let's connect to your server now that it is up and running. Then you can play!
Launch Minecraft Java Edition. In the menu, select Multiplayer.
Next, add a server to connect. Click on the Add Server button.
The Edit Server Info screen opens. Give your server name and enter your server's IP address. This is the IP address that you used for SSH connection.
Once you have entered your server name and IP address, you'll be taken back to the Multiplayer screen where your server will now be listed.
Your server will now always be listed in this list. Click on it and click Join Server.
You are now in control of your server and are ready to play.
You now have a Minecraft server running on Ubuntu 20.04 for you and all of your friends to play on! Have fun exploring, crafting, and surviving in a crude 3D world. strongcraft.org Be aware of griefers.