Introduction

A Minecraft server will let you play online with other people. In this article, we are going to install a Minecraft server on Ubuntu 18.04.

Prerequisites

  • Ubuntu 18.04
  • Java
  • A non-root sudo user
  • At least 1GB of RAM. While Minecraft can operate on less, you may run into memory issues
  • Screen (optional)

Before you begin

Create a new non-root user with sudo access:

adduser mcuser

Add mcuser to the sudo group:

usermod -aG sudo mcuser

Switch to the new sudo user:

su - mcuser

Update your system:

sudo apt update && sudo apt upgrade -y

Install wget, if it's not already installed:

sudo apt install wget

Installation

In order to run a Minecraft server, we will need Java on the server. Install the latest version:

sudo apt install openjdk-8-jdk -y

Now, confirm the Java installation:

sudo java -version

You will receive output similar to the following:

openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

You can also install Screen, if you want the Minecraft server to be able to run in the background:

sudo apt install screen -y

Create a new directory to hold all of your Minecraft files, and move to that directory:

sudo mkdir minecraft && cd minecraft

Now we can install Minecraft. Be sure to replace 1.11.2 with the current release of Minecraft:

sudo wget -O minecraft_server.jar https://s3.amazonaws.com/Minecraft.Download/versions/1.11.2/minecraft_server.1.11.2.jar
sudo chmod +x minecraft_server.jar

The Minecraft installation is now complete, but you must accept the license agreement before you can use it:

sudo vim eula.txt

Find the line eula=false and change it to eula=true. Save and exit.

You can now start your Minecraft server:

sudo java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

This command starts the Minecraft server with 1024MB RAM allocated. To allocate more RAM, simply change the -Xmx and -Xms arguments to your desired size. For example, -Xmx2048M -Xms2048M will start the server with 2048MB RAM.

If you want to run the server in the background, first stop the server that is currently running with the command stop. Now create a new Screen instance.

sudo screen -S "My Minecraft Server"

Now run the Java command again:

sudo java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

To exit out of the screen window, press CTRL + A, then press D. If you want to open the window again, use the command sudo screen -r.

Congratulations, you now have a Minecraft server up and running on Ubuntu 18.04.

آیا این پاسخ به شما کمک کرد؟ 1 کاربر این را مفید یافتند (1 نظرات)