How To Create A Minecraft Server On Ubuntu 2004

From Clash of Crypto Currencies
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 popular sandbox 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-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 there is DigitalOcean’s One Click Minecraft: Java Edition Server.



This tutorial uses the Java version of Minecraft. You won't be able to connect if you bought Minecraft through the Microsoft App Store. Most Minecraft versions purchased on gaming consoles, such as the PlayStation 4 or Xbox One, are also compatible with the Microsoft version. These consoles cannot connect to the server created in this tutorial. You can download the Java version here.



Prerequisites



You will need the following items to follow this guide:



- A server with a fresh installation of Ubuntu 20.04, a non-root user with sudo privileges, and SSH enabled. To initialize your server, follow this guide. Minecraft can be resource-intensive. Keep this in mind when you select your server size. DigitalOcean can be used to increase the resources of your Droplet.



- Minecraft Java Edition installed on a local Mac or Windows machine.



Step 1 - Install the necessary software packages and configure the firewall



With your server initialized, your first step is to install Java; you'll need it to run Minecraft.



Update the package indice for the APT manager package manager



sudo apt-update Next, install OpenJDK version 16 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. 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: 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.



You can now use the copied link and wget 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. 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.



First, start a screen session by running the screen command:



screen After you have read the banner, press the SPACE button. The screen will display a terminal session just like normal. This session can now be detached, so you can start a command and then leave it running.



Now you can 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. You will do this next.



1. java -Xms1024M -Xmx1024M -jar minecraft_server_1.15.2.jar nogui Before we look at the command's output, let us take a closer look to all of these command-line parameters that are tuning your server.



- Xms1024M -- This allows the server's RAM to be set up to either 1024MB, or 1GB. You can increase this limit if your server needs 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 sets the server to only use 1024M in 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 jar 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.



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. These errors were caused by the server not being able to locate the files. It created them in your current work 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 a web browser and go through the agreement. Next, open your text editor and locate the last line of eula.txt. This will change eula=false into eula=true. Save and close this file.



Now that you have accepted the EULA it is time for you to configure the server according 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. The Official Minecraft Wiki has a complete list of all server properties. Before you can start your server you can modify this file to suit your preferences. This tutorial will discuss the fundamental 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 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 sets the gameplay mode. The options are 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've set the options you want, save the file. Wanna talk about minecraft



Now that you have changed EULA to true and configured your settings, you can successfully 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 fit the server's requirements or server limitations.



1. java -Xms1024M -Xmx4G -jar minecraft_server_1.15.2.jar nogui Give the initialization time. 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 You will see this output:



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 - 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 This output will contain the ID of your session. You'll need this ID to resume the 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. You can then play!



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



Next, you'll need to add a new server to connect to. Click on "Add Server" to proceed.



In the Edit Server Info screen, give your server an address and type in your IP address. This is the same IP address you used to connect via 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 appear in this list. Select it and click Join Server.



You are now in your server and ready for play! Wanna talk about minecraft



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. Remember to be careful of griefers.