Return to site

How To Create A Minecraft Server On Ubuntu 20.04

  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 popular sandbox game. Originally released in 2009, it allows players to build, explore, craft, and survive in a block 3D generated world. It was the second most popular 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. Finally, you will deploy the game. Alternately there is DigitalOcean’s One Click Minecraft: Java Edition Server. This tutorial uses the Java version of Minecraft. If you purchased your version of Minecraft through the Microsoft App Store, you will be unable to connect to this server. Most Minecraft versions that are purchased on gaming consoles (e.g., the PlayStation 4, Xbox One, Nintendo Switch) also come with the Microsoft version. These consoles cannot connect to the server created in this tutorial. The Java version of Minecraft can be downloaded here. Prerequisites This guide will be followed if you have: - A server that has Ubuntu 20.04 installed, with a non-root user having sudo privileges and SSH disabled. 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 installed on a local Mac or Windows 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 release that does not support GUI apps. 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 to create a terminal and then detach from it. This will allow you to continue the process. This is important, as if the session were to close and you tried to restart your server, it would kill it and cause your server to stop. 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 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. 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. To download the server, you will need to use wget with 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. But this tutorial will focus on the current latest release. MINECRAFT SERVERS 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 After reading the banner, press and hold the SPACE key. screen will present you with a terminal session like normal. 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 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 Let's first examine the output of this command. Next, let's look at all the command-line arguments that are tuning your server. - Xms1024M This will allow the server to be started with either 1024MB or 1GB RAM. This limit can be increased if you need 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 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 jar file is to be run by the server. - nogui: This tells a server not to launch any GUI since it is a server. This command normally starts your server. It will generate the following error instead. 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. The server was unable find these files and created them in your current directory. First, open eula.txt in 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 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 this file. 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 complete list on the Official Minecraft Wiki of all server property information. This file can be modified with your preferred settings, before you start your server. This tutorial will discuss the fundamental properties. nano server.properties The following image will be displayed on your file: Let's take a closer view at some of these most important properties: - difficulty (default easy) - This sets the difficulty of the game, such as how much damage is dealt and how the elements affect your player. The options are peaceful, easy, normal, and hard. - gamemode (default Survival) - This controls the gameplay mode. There are three options available: 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 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 have chosen the options you desire, save and close your 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. Let's now give Minecraft the ability to use 4G RAM if it so desires. Remember, you are welcome to adjust this number to fit your server limitations or user needs: 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 This output will be available: From this terminal you can execute administrator commands and control your Minecraft server. Now let's use screen to keep your new server running, even after you log out. Next, you can connect to Minecraft and start a new Minecraft server. Step 4 – Keeping 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 disconnect from the session using screen by pressing Ctrl+ A + D. This command will display all 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 the -r flag to the screen command and then enter your session ID: screen -r 26653 When you are ready to log out of your server, be sure to detach from the session with Ctrl + A + D and then log out. 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. Then you can play! Launch your copy of Minecraft Java Edition and select Multiplayer in the menu. 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 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 in your server and 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.

MINECRAFT SERVERS