How To Create A Minecraft Server On Ubuntu 2004

From Wifi Adapters DB
Jump to: navigation, search

The Tech Education Fund was selected by the author to receive a donation under the Write for DOnations program.



Introduction



Minecraft is a well-known sandbox videogame. It was released in 2009 and allows players the freedom to create, explore, craft, or survive in a 3D-generated block world. As of late 2019, it was the second best-selling video game of all time. 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, DigitalOcean's One Click Minecraft: Java Edition Server is another installation option.



This tutorial uses the Java version of 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 will not connect to the server that was built in this tutorial. You can obtain the Java version of Minecraft here.



Prerequisites



In order to follow this guide, you'll need:



- A server that has Ubuntu 20.04 installed, with a non-root user having sudo privileges and SSH disabled. This guide will help you to set up your server. Minecraft can be resource intensive, so consider this when deciding on the size of your server. DigitalOcean can be used to increase the resources of your Droplet.



- Minecraft Java Edition on a local Mac, Windows or Linux.



Step 1: Install the required software packages and configure your firewall



Once your server is up and running, you can install Java. This is essential for Minecraft to run.



Update the package indice for the APT manager package manager



sudo apt update Next, install the OpenJDK version 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 apt 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. 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: Download 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. But this tutorial will focus on the current latest release. 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 you have read the banner, press the SPACE button. 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.



You can now perform your initial configuration. Do not panic if this command throws an error. Minecraft designed its installation so that users must agree to the company's licensing agreements. This is what you will do 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 tells the server to start with 1024MB of RAM or 1GB. This limit can be increased if you need more RAM. You have two options: M for megabytes andG for gigabytes. For example, Xms2G will launch the server with 2 gigabytes RAM.



- Xmx1024M This allows the server to use a maximum of 1024M RAM. You can raise this limit if you want your server to run at a larger size, allow for more players, or if you feel that your server is running slowly.



- Jar - This flag specifies which jar file is to be run by the server.



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



The first time you run this command, which normally starts your server, it will instead generate the following error:



These errors were generated by the server failing to find the two required files for execution: the EULA, End User License Agreement, found in eula.txt. and the configuration.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 Inside this file, you will see a link to the Minecraft EULA. Copy the URL.



Open the URL in your web browser and read the agreement. Return to your text editor, and then find the last line in "eula.txt". Change eula=false here to eula=true. Save the file and close it.



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. The Official Minecraft Wiki has a complete list of all server properties. This file can be modified with your preferred settings, before you start your server. This tutorial will cover the fundamental properties:



nano server.properties Your file will look something like this:



Let's take a closer look at some of the most important properties in this list:



- 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 options: normal, peaceful, hard, normal, and easy.



- gamemode (default survival) - This sets 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 as the apostrophe may need to be escaped with 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 this setting is true, players can engage each other in combat and damage.



Once you have set the options that you want, save and close the file.



After you have set your settings to true and changed EULA to true, you can now successfully start your server.



Let's continue the same way as last time and start our server with 1024M of RAM. Let's give Minecraft access up to 4G of RAM. 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 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 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. 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



Once you have set up your server, you want it running even after you disconnect. 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 -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



Now that your server is up and running, let's connect to it through the Minecraft client. Now you can play!



Start Minecraft Java Edition. Click Multiplayer to open the menu.



Next, you will need to add a server to connect to, so 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 exact IP address that was used to connect through SSH. Srazy



Once you have entered your server name, IP address, you will be taken back to Multiplayer screen. Your server will now be listed.



Your server will now always be listed in this list. Select it, and then 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, and surviving in a crude 3D world. Beware of griefers.