How To Create A Minecraft Server On Ubuntu 2004

From Fake News
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. 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. In this tutorial, you will install the necessary software to run Minecraft, configure it to run, then deploy the game.



Alternately, DigitalOcean's One Click Minecraft: Java Edition Server is another installation option.



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 Minecraft versions purchased on gaming consoles, such as the PlayStation 4 or Xbox One, are also compatible with the Microsoft version. These consoles are also unable to connect to the server built in this tutorial. The Java version of Minecraft can be downloaded here.



Prerequisites



To follow this guide, you will need:



- 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, so keep that in mind when selecting your server size. DigitalOcean may require more resources. Thinkofdeath You can always resize Droplets to add more CPUs or RAM.



- Minecraft Java Edition installed locally on a Mac, Windows, or Linux computer.



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 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 without support for GUI applications. 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 to create a terminal session and detach from it, leaving the process started on it running. This is important as if you start your server and then close the terminal, it will kill the session and terminate 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 only allowed traffic via SSH during the initial server setup. Now you need to allow for traffic to come in via port 25565, which is the default port that 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: 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.



Start a screen session first by running the screen command



screen Once you have read the banner that has appeared, press the SPACE bar. You will see a terminal session as normal. This session is now detachable, which means that you'll be able to start a command here and leave it running.



You can now perform your initial configuration. Do not be alarmed when this next command throws an error. Minecraft's installation is designed so that users have to agree to the company licensing agreement. This is what you will do 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. You can raise this limit if you want your server to start with more RAM. Both M for megabytes as well as G for gigabytes can be used. For example, Xms2G will launch the server with 2 gigabytes 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 to not launch a GUI because this is a server and you don’t have a 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. 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 This file contains a link 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". Here, change eula=false to eula=true. Save and close the 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. You will modify this file with your preferred settings before starting your server. This tutorial will discuss the fundamental properties.



nano server.properties This is how your file will look like:



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



- difficulty (default, easy) – This defines the difficulty of your game. This includes how much damage is dealt and how elements affect your player. There are four options available: peaceful, easy, normal, or hard.



- Gamemode (default survival) – This determines the game mode. The options are survival, creative,adventure, and spectator.



- level-name (default universe) - This is the name of the server that will be displayed in the client. Characters such as an apostrophe might need to be escape 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.



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



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



You have been dropped into the server administrator panel. Your server is now up and running. Now, type help.



help This output will be available:



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



Now that you have your server up, you want it to remain running even after 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 view all 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. After that, enter your sessionID:



screen –r 26653 Be sure to detach the session from your server with Ctrl+A + D before you 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. You can then play!



Launch your copy of Minecraft Java Edition and select Multiplayer in the menu.



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



In the Edit Server Info screen that shows up, give your server a name and type in the IP address of your server. 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.



This list will continue to show your server's name. Click on it and 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! Enjoy exploring, crafting, and surviving within a primitive 3D world. And remember: watch out for griefers.