How To Create A Minecraft Server On Ubuntu 2004

From Men's
Jump to: navigation, search

The author selected the Tech Education Fund to receive a donation as part of the Write for DOnations program.



Introduction



Minecraft is a popular sandbox video game. It was originally released in 2009 and allows players to explore, build, craft, survive, and create a block 3D 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. Specifically, you will install the necessary software packages to run Minecraft, configure the server to run, and then deploy the game.



Alternately, you can explore DigitalOcean's One-Click Minecraft: Java Edition Server as another installation path.



This tutorial uses Java Minecraft. You will not be able to connect to the server if you purchased Minecraft from the Microsoft App Store. Most versions of Minecraft purchased on gaming consoles such as the PlayStation 4, Xbox One, or Nintendo Switch are also the Microsoft version of Minecraft. These consoles are not able to connect to this tutorial's server. The Java version of Minecraft can be downloaded here.



Prerequisites



This guide will be followed if you have:



- A server with a fresh installation of Ubuntu 20.04, a non-root user with sudo privileges, and SSH enabled. This guide will help you to set up your server. Minecraft can be resource-intensive. Keep this in mind when you select 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 required software packages and configure your firewall



After your server is initialized, the next step is to install Java. It's necessary to run Minecraft.



Update the package indice for the APT manager package manager



sudo apt upgrade Next, install OpenJDK 16 of Java, specifically, the headless JRE. This is a minimal Java release that does not support GUI apps. 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 create a terminal session, then detach it from it. The process will continue as normal. This is important because if you were to start your server and then close your terminal, this would kill the session and stop 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. minecraft servers You allowed traffic only from SSH in the initial server setup. Now you must allow traffic to come in via port 25565, which is the default port Minecraft uses to allow connections. Add the necessary firewall rule by running the following command:



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.



You can now use wget and the copied link to download the server:



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 first by running the screen command



screen After reading the banner, press and hold the SPACE key. You will see a terminal session as normal. 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. If the next command throws errors, don't panic. 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 we examine the output of this command, let's take a closer glance at all the command line arguments, which are tuning you server.



- Xms1024M: This tells the server to start with 1024MB of RAM or 1GB. If you wish to have more RAM, you can increase this limit. 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. If you wish your server to run at higher speeds, allow for more players, and if your server is running slow, you can increase this limit.



- 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, which normally starts your web server, will return the following error when it is run for the first time:



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 using nano or your favorite text editor.



nano eula.txt You will find a link within this file to the Minecraft EULA. Copy the URL.



Open the URL in your browser and read the agreement. Return to your text editor, and then find the last line in "eula.txt". This will change eula=false into eula=true. Save and close this file.



Now that you've accepted the EULA, it is time to configure the server to your specifications.



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 detailed list of all server properties on the Official Minecraft Wiki. Before you can start your server you can modify this file to suit your preferences. This tutorial will explain the basic properties.



nano server.properties Your file will appear like this:



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



- difficulty (default: easy) - This controls the difficulty of the game. It determines how much damage is dealt to your player and how the elements affect them. There are four choices: easy, normal and hard.



- gamemode (default Survival) - This controls the gameplay mode. There are three options: survival; creative; adventure; and spectator.



- level–name (default realm) - This defines the name of your server and will be displayed 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 will have the ability to damage and engage in combat.



After you have selected the options you wish, save the file and close it.



You can now start your server successfully after you have changed the EULA to true.



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. You are free to adjust this number to suit your server limitations or user requirements.



1. java -Xms1024M -Xmx4G -jar minecraft_server_1.15.2.jar nogui Give the initialization process a few seconds. Soon your new Minecraft server will start producing an output similar to this:



Once the server has been up and running, the following output will be displayed:



Now your server has started and you are able to access the server administrator control panels. Now type help.



Help This output will be available:



From this terminal you can execute administrator commands and control your Minecraft server. 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 - Keep 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 view all 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 -r to the screen command. Next, enter your session ID.



screen -r 266553 You can log out of your server by detaching from the session using Ctrl +A + D, and then 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. Now you can start playing!



Launch Minecraft Java Edition. In the menu, select Multiplayer.



Next, click on the Add Server button to add a server.



The Edit Server Info screen opens. Give your server name and enter your server's IP address. This is the same IP address that you used to connect through SSH.



Once you've entered your server name or IP address, you'll return to the Multiplayer screen. Here your server will be listed.



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



You are now in your server and ready for play!



You now have a Minecraft server running on Ubuntu 20.04 for you and all of your friends to play on! Enjoy exploring, crafting, and surviving within a primitive 3D world. Be aware of griefers.