How To Create A Minecraft Server On Ubuntu 2004

From Valentino Fans
Jump to: navigation, search

The Tech Education Fund was chosen by the author as a recipient of a donation in the Write for DOnations program.



Introduction



Minecraft is a very popular sandbox videogame. 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-sold 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. The Microsoft version of Minecraft is also available for most Minecraft versions purchased on gaming consoles like the PlayStation 4, Xbox One or Nintendo Switch. These consoles cannot connect to the server created in this tutorial. The Java version of Minecraft can be downloaded here.



Prerequisites



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



- A server running Ubuntu 20.04 with sudo privileges and SSH enabled. Follow this guide to setup 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.



- A copy of Minecraft Java Edition installed on a local Mac, Windows, or Linux machine.



Step 1: Install the required software packages and configure your 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 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 apps 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 the creation of a terminal session and its detachment, while still allowing the process to run. 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. In the initial server setup that you performed you only allowed traffic from SSH. Now you need to allow for traffic to come in via port 25565, which is the default port that Minecraft uses to allow connections. Run the following command to add firewall rules:



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 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 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.



Start a screen session by running this screen command:



Screen After you have read the banner, press the SPACE button. The screen will display a terminal session just like normal. Minecraft online This session is now detachable, which means that you'll be able to start a command here and leave it running.



Now you can execute your initial configuration. Don't be alarmed if the next command throws an Error. Minecraft has designed its installation this way so that users must first consent to the company's licensing agreement. Next, you will need to do this:



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. You can increase this limit if your server needs more RAM. You can choose between M for megabytes or G for gigabytes. 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 raised if you wish to allow more players or if the 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 will not normally start your server the first time it is run. Instead, it will produce the following error



These errors were generated because the server could not find two necessary files required for execution: the EULA (End User License Agreement), found in eula.txt, and the configuration file server.properties. These errors were caused by the server not being able to locate the files. It created them in your current work directory.



First, open eula.txt using 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 web browser and read the agreement. Next, return to your text editor. Find the last line of eula.txt. Here, change eula=false to eula=true. Save and close the file.



Now that you have accepted and confirmed the EULA, it's time to configure your 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. 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 explain the basic properties.



nano server.properties The following image will be displayed on your file:



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



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



After you've set the options you want, save the 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. We can also give Minecraft access to up to 4G RAM, if Minecraft needs it. This number can be adjusted to fit the server's requirements or server limitations.



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:



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



Your server is now running, and you have been dropped into 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 use screen now to keep your server running after you log in. 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. You can disconnect from the session using screen by pressing Ctrl+ A + D.



Run this command to see all of your screen sessions:



screen –list You'll receive an output with the session ID, which you will need to resume that session.



To resume your session, pass the -r flag to the screen command and then 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 has been set up, let's connect it using the Minecraft client. Then you can play!



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



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 exact IP address that was used to connect through SSH.



Once you have entered your server name, IP address, you will be taken back to Multiplayer screen. 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 now 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 3D world. Be aware of griefers.