How To Create A Minecraft Server On Ubuntu 2004

From Champion's League Wiki
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 released in 2009 and allows players the freedom to create, explore, craft, or survive in a 3D-generated block 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 to run Minecraft and configure the server to run. ebookmarks Finally, you will deploy the game.



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



This tutorial uses Java Minecraft. You won't be able to connect if you bought Minecraft 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 are also unable to connect to the server built in this tutorial. The Java version can be found here.



Prerequisites



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



- A server with Ubuntu 20.04 installed. 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 may require more resources. You can always resize Droplets to add more CPUs or RAM.



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



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 to the APT Package Manager:



sudo update Next, download the OpenJDK Version 16 of Java. This includes the headless JRE. This is a minimal Java version that does not support GUI applications. This makes it ideal to run 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 installation 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. Run the following command to 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 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. 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, open a screen session using 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 removable, which means you can launch a command from here and then quit it.



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. This is what you will do 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 configures the server to start running with 1024MB or 1GB of RAM running. This limit can be increased if you need more RAM. You have two options: M for megabytes andG for gigabytes. For example, Xms2G starts the server with 2 gigabytes (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 server not to launch a GUI as this is a client.



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



These errors were caused by the server not finding two files necessary for execution: the EULA (End User License Agreement), located in eula.txt and the configuration fileserver.properties. The server was unable find these files and created them in your current directory.



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



nano eula.txt You will find a link in 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". Change eula=false here to eula=true. Save the file and close it.



Now that you have accepted the EULA it is time for you to configure the server according 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. 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 focus on the most important properties.



nano server.properties Your file will look something 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 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 true, players can engage in combat with each other and cause damage.



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.



Let's continue the same way as last time and start our 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 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 is running and you have been redirected to the server administrator control panel. Now type help:



Help This is how you will get an output like this:



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 - Keep the server running



Once your server is set up, you want the server to continue running even if you disconnect from your SSH session. You can detach from this session using screen as a shortcut. Press Ctrl +A + D to return to 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 26653 Once you are ready to log off of your server, make sure to disconnect from the session by pressing Ctrl+ A + D. Then log off.



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. You can then play!



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



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



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 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 then click Join Server.



You are now in control of your server and are 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. Remember to be careful of griefers.