Description

How To Create A Minecraft Server On Ubuntu 20.04

The Tech Education Fund was the recipient of a donation from Write for DOnations.


Introduction


Minecraft is a popular sandbox game. Originally released in 2009, it allows players to build, explore, craft, and survive in a block 3D generated world. It was the second most popular video game in 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 for Minecraft, configure the server, and then deploy it.


Alternately you can also explore DigitalOcean’s One-Click Minecraft Java Edition Server as an alternative installation path.


This tutorial uses the Java version of 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. The Java version of Minecraft can be downloaded here.


Prerequisites


To follow this guide, you will need:


- A server that has Ubuntu 20.04 installed, with a non-root user having sudo privileges and SSH disabled. You can follow this guide to initialize your server and complete these steps. Minecraft can be resource-intensive so make sure to consider this when choosing the size of your server. DigitalOcean can be used to increase the resources of your Droplet.


- Minecraft Java Edition installed locally on a Mac, Windows, or Linux computer.


Step 1 - Installing 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 of the APT package manger:


sudo apt-update Next, install OpenJDK version 16 Java, specifically the headless JRE. This is a minimal Java version that does not support GUI applications. This makes it perfect for running Java applications on servers.


sudo apt install openjdk-16-jre-headless You also need to use a software called screen to create detachable server sessions. screen allows the creation of a terminal session and its detachment, while still allowing the process to run. This is important because if your server were to be started and then closed your terminal, it would kill the session. 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. You allowed traffic only from SSH in the initial server setup. You must now allow traffic to port 25565 to access Minecraft. 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 Minecraft Version


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 will need to use wget with 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 concentrate on the current 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.


First, open a screen session using the 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 can now be detached, so you can start a command and then leave it running.


Now you can perform your initial configuration. Don't be alarmed if the next command throws an Error. Minecraft's installation was designed in a way that users must consent to the company’s licensing agreement. You will do this next:


1. java -Xms1024M -Xmx1024M -jar minecraft_server_1.15.2.jar nogui


Let's first examine the output of this command. Next, let's look at all the command-line arguments that 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. Both M for megabytes and G for gigabytes are supported options. For example, Xms2G would start the server with two gigabytes worth of RAM.


- Xmx1024M: This tells the server that it can only use 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 file to run.


- nogui - This tells the server not to launch a GUI since this is a server, and you don't have a graphical user interface.


This command will not normally start your server the first time it is run. Instead, it will produce the following error


These errors were created because the server couldn't find two files that were required for execution: The EULA (End User License Agreement), which can be found in the eula.txt file, and the configuration.properties. Fortunately, since the server was unable to find these files, it created them in your current working directory.


First, open eula.txt in nano or your favorite text editor:


nano eula.txt


This file contains a link to the Minecraft EULA. Copy the URL:


Open the URL in your browser and read the agreement. Next, open your text editor and locate the last line of eula.txt. Change eula=false here to eula=true. Now save and close the file.


Now that the EULA has been accepted, it is time configure the server to your requirements.


The new server.properties file will be located in your current working folder. This file contains all of the configuration options for your Minecraft server. You can find a complete list on the Official Minecraft Wiki of all server property information. This file can be modified with your preferred settings, before you start your server. This tutorial will discuss the fundamental properties.


nano server.properties


The following image will be displayed on your file:


Let's take a closer view at some of these most important properties:


- difficulty (default is easy) – This determines the difficulty of a game, such how much damage you are dealt and how the elements impact your player. There are four choices: easy, normal and hard.


- Gamemode (default survival) – This determines the game mode. There are three options available: 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 set to true, players will be able to engage in combat and damage each other.


After you have chosen the options you desire, save and close your file.


Now that you have set the EULA to true as well as your settings, you are ready to start your server.


Like last time, let's start your server with 1024M of RAM. Let's now give Minecraft the ability to use 4G RAM if it so desires. 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 moment. Soon your new Minecraft server will start producing an output similar to this:


After the server is up, you will see this output:


You have been dropped into the server administrator panel. Your server is now up and running. Now type help:


Help


An output like this will appear:


From this terminal you can execute administrator commands and control your Minecraft server. Minecraft servers Now let's use screen to keep your new server running, even after you log out. 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. Minecraft servers Since you used screen earlier, you can detach from this session by pressing Ctrl + A + D. Now you're back in your original shell.

Run this command to view all screen sessions


screen -list This output will contain the ID of your session. You'll need this ID to resume the session.


To resume your session, pass the -r flag to the screen command and then enter your session ID:


screen -r 26653 When you are ready to log out of your server, be sure to detach from the session with Ctrl + A + D and then log out.


Step 5 - Connecting to the Minecraft Server from the Minecraft Client


Now that your server has been set up, let's connect it using the Minecraft client. Now you can start playing!


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 same IP address you used to connect via SSH.


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.


From now on your server will always be visible in this list. Select it and click Join Server.


You are in your server and 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, surviving, and creating in a 3D world. And remember: watch out for griefers.

Listing

Sorry, no listings were found.