How To Create A Minecraft Server On Ubuntu 2004

From Marvel vs DC
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 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. 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 Java Minecraft. You will not be able to connect to the server if you purchased Minecraft from the Microsoft App Store. Top minecraft servers 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 can be found here.



Prerequisites



To follow this guide, you will need:



- A server running Ubuntu 20.04 with sudo privileges and SSH enabled. This guide will help you to set up your server. Minecraft can be resource-intensive so make sure to consider this when choosing the size of your server. DigitalOcean allows you to resize your Droplet to increase CPUs and RAM.



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



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



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



Update the package index to the APT Package Manager:



sudo apt upgrade Next, install OpenJDK 16 of Java, specifically, the headless JRE. This is a minimal Java version without support for 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 your server were to be started and then closed your terminal, it would kill the session. 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. 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 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 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 only cover the latest 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.



First, open a screen session using the screen command.



screen After reading the banner, press and hold the SPACE key. This will open a terminal session, just as usual. 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 has designed its installation this way so that users must first consent to the company's licensing agreement. Top minecraft servers 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 can choose between M for megabytes or G for gigabytes. For example: Xms2G will start the server with 2 gigabytes of 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 jar file is to be run by the server.



- Nogui - This tells server not to launch a GUI as this is a client.



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 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 Inside this file, you will see a link to the Minecraft EULA. Copy the URL.



Open the URL in a web browser and go through the agreement. Then return to your text editor and find the last line in eula.txt. Change eula=false here to eula=true. Save and close this file.



Now that you've accepted the EULA, it is time to configure the server to your specifications.



In your current working directory, you will also find the newly created server.properties file. 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 cover the fundamental 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 defines the difficulty of your game. This includes how much damage is dealt and how elements affect your player. The options are peaceful, easy, normal, and hard.



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



- level_name (default world), - This determines the name of your server, which will be displayed in 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'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.



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. 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 time. 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 An output like this will appear:



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 your server is up, you want it continue to run even after you disconnect from SSH. You can detach from this session using screen as a shortcut. Press Ctrl +A + D to return to your original shell.



This command will display 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. Now you can start playing!



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 will open. Give your server a name and enter the IP address of the server. This is the same IP address that you used to connect through SSH.



Once you have entered the server name and IP address you will be taken to the Multiplayer screen, where your server will now appear.



This list will continue to show your server's name. 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 crude 3D world. Remember to be careful of griefers.