Install Minecraft Server on Ubuntu LTS

Posted on

Install Minecraft Server on Ubuntu LTS

Install Minecraft Server on Ubuntu LTS

Introduction

Minecraft, a creation of Markus Persson and brought to life by Mojang Studios, stands as a monumental sandbox video game. Players are dropped into a blocky, procedurally generated 3D realm, brimming with opportunities to construct, craft, and collaborate.

A Minecraft server acts as the central hub, enabling players to connect and share the Minecraft experience across the internet or a local network. By self-hosting, players can build and explore worlds with friends, regardless of physical location. Setting up a Minecraft server is achievable on various operating systems, including Windows, macOS, and Linux. This guide provides a step-by-step process for deploying a Minecraft server on Ubuntu-based systems: 18.04 / 20.04 / 22.04.

Update the system

Before diving into the installation, ensure your Ubuntu system is up-to-date. This step is crucial for security and stability. Execute the following commands:

$ sudo apt update && sudo apt upgrade

This command synchronizes your system’s package list with the repositories and upgrades any outdated packages.

Install Java 17

Minecraft servers require Java to function. Version 17 is recommended for optimal performance and compatibility with recent Minecraft server versions. Install it using the following command:

$ sudo apt install openjdk-17-jdk

This command fetches and installs the OpenJDK 17 Java Development Kit.

Create a user for the Minecraft server

For enhanced security, it’s recommended to run the Minecraft server under a dedicated user account. This isolates the server process and limits potential damage from security breaches. Create a new user named "minecraft" using the following command:

$ sudo adduser minecraft

You’ll be prompted to set a password for the new user. Choose a strong, unique password.

Switch to the minecraft user

Now, switch to the newly created "minecraft" user. This ensures that subsequent commands are executed under the context of this user.

$ sudo su - minecraft

This command logs you in as the "minecraft" user, changing your current working directory to the user’s home directory.

Download the Minecraft server software

Download the Minecraft server software. At the time of writing, version 1.19.3 is the latest stable release. You can use wget to download the server .jar file directly from Mojang.

$ wget https://piston-data.mojang.com/v1/objects/c9df48efed58511cdd0213c56b9013a7b5c9ac1f/server.jar

This command downloads the server.jar file to the current directory.

Start the Minecraft server

Start the Minecraft server with a specified amount of RAM. The -Xmx and -Xms parameters control the maximum and initial heap size, respectively.

$ java -Xmx1024M -Xms1024M -jar server.jar nogui

This command launches the Minecraft server. The nogui option disables the graphical user interface, running the server in a command-line environment.

Accept the EULA

Upon the first launch, the server will generate an eula.txt file. You must accept the End User License Agreement (EULA) to proceed.

$ nano eula.txt

Open the eula.txt file in a text editor. Change eula=false to eula=true and save the file.

Restart the server

Stop the server by typing stop in the Minecraft console. Then, restart the server with the same command as before:

$ java -Xmx1024M -Xms1024M -jar server.jar nogui

Edit server.properties

The server.properties file allows you to configure various aspects of your Minecraft server, such as the game mode, difficulty, maximum number of players, and more.

$ nano server.properties

Here are some key settings you might want to adjust:

  • level-seed=: A seed value for generating the world. Leave blank for a random seed.
  • gamemode=survival: The game mode. Options include survival, creative, adventure, and spectator.
  • difficulty=easy: The difficulty level. Options include peaceful, easy, normal, and hard.
  • max-players=20: The maximum number of players allowed on the server.
  • motd=My Minecraft Server: The message of the day (MOTD) displayed in the server list.
  • online-mode=true: Set to false to disable authentication with Mojang’s servers (not recommended for public servers).

Save the file after making your desired changes.

Configure firewall rules

If you have a firewall enabled on your Ubuntu server (which is highly recommended), you need to allow incoming traffic on port 25565, the default Minecraft server port.

$ sudo ufw allow 25565/tcp

This command configures the Uncomplicated Firewall (UFW) to allow TCP traffic on port 25565.

Test the Minecraft server

Finally, test the Minecraft server by connecting to it from another device on the same network. Use the IP address of the Ubuntu server and the default port 25565.

You should now have a fully functioning Minecraft server version 1.19.3 running on Ubuntu with Java 17 and a configured server.properties file.

Alternative Solutions for Installing a Minecraft Server on Ubuntu LTS

While the previous method details a manual installation, alternative approaches can simplify the process and offer additional features. Here are two such alternatives:

1. Using Docker

Docker provides a containerization solution that allows you to run applications in isolated environments. This approach streamlines the installation process and ensures consistency across different systems.

Explanation:

Docker packages the Minecraft server and its dependencies into a container, eliminating the need to manually install Java or configure the environment. This ensures that the server runs consistently regardless of the underlying operating system. Docker also simplifies updates and management, as you can easily update the container to the latest version.

Steps:

  1. Install Docker: If Docker isn’t already installed on your system, install it using the following command:

    sudo apt update
    sudo apt install docker.io
  2. Pull a Minecraft Server Docker Image: Several pre-built Docker images are available for Minecraft servers. One popular option is itzg/minecraft-server. Pull the image using the following command:

    docker pull itzg/minecraft-server
  3. Run the Docker Container: Create a directory to store the Minecraft server data. This is important for persisting your world data.

    mkdir minecraft_data

    Run the container with the following command, replacing /path/to/minecraft_data with the actual path to the directory you created:

    docker run -d -p 25565:25565 -e EULA=TRUE -e VERSION=1.19.3 -v /path/to/minecraft_data:/data itzg/minecraft-server
    • -d: Runs the container in detached mode (in the background).
    • -p 25565:25565: Maps port 25565 on the host to port 25565 in the container.
    • -e EULA=TRUE: Accepts the EULA.
    • -e VERSION=1.19.3: Specifies the Minecraft server version.
    • -v /path/to/minecraft_data:/data: Mounts the host directory /path/to/minecraft_data to the container’s /data directory, where the server data is stored.
  4. Configure the Server: The server.properties file and other server configurations are located in the /path/to/minecraft_data directory. You can edit these files to customize your server.

This method provides a more streamlined and manageable way to deploy a Minecraft server.

2. Using AMP (Application Management Panel)

AMP is a web-based control panel specifically designed for managing game servers, including Minecraft.

Explanation:

AMP provides a user-friendly interface for installing, configuring, and managing your Minecraft server. It automates many of the manual steps involved in the standard installation process, making it easier for users with less technical experience. It also offers features like server monitoring, automatic backups, and mod management.

Steps:

  1. Install AMP: AMP requires a license, but offers a free trial. The installation process varies depending on your chosen distribution (AMP Standard, AMP Professional, etc.). Refer to the official AMP documentation for detailed instructions (https://cubecoders.com/AMP). Generally, it involves downloading an installer script and running it.

  2. Create a Minecraft Instance: Once AMP is installed and running, access the web interface through your browser. Create a new instance and select "Minecraft" as the application type. AMP will guide you through the process of downloading and installing the Minecraft server software.

  3. Configure the Server: AMP provides a graphical interface for configuring the server.properties file and other server settings. You can easily adjust the game mode, difficulty, maximum number of players, and other options through the web interface.

  4. Manage the Server: AMP allows you to start, stop, and restart the server, as well as monitor its performance and manage backups. It also provides tools for managing mods and plugins.

This approach provides a more user-friendly and feature-rich way to manage your Minecraft server, especially for users who prefer a graphical interface.

By exploring these alternative solutions, you can choose the method that best suits your technical skills and server management needs. Each approach offers different advantages and disadvantages in terms of ease of use, flexibility, and features. The Install Minecraft Server on Ubuntu LTS process can be tailored to individual preferences and requirements. Remember to always keep your server software and system up to date to ensure optimal performance and security. Setting up a Minecraft server on Ubuntu LTS using Docker or AMP simplifies the Install Minecraft Server on Ubuntu LTS process significantly.

Leave a Reply

Your email address will not be published. Required fields are marked *