The cart is empty

Minecraft stands as one of the most popular games globally, offering not just gameplay on personal computers and gaming consoles but also on servers. This article serves as a walkthrough for installing a Minecraft server on a Linux-based server. While focusing on Ubuntu distribution, the steps should be similar for most Linux distributions.

Prerequisites

Before initiating the installation, ensure your Linux server meets the following requirements:

  • Modern Linux distribution (e.g., Ubuntu 20.04 LTS)
  • SSH access to the server
  • At least 1 GB of free RAM (recommended 2 GB or more for better performance)
  • Java Runtime Environment (JRE) installed on the server

Step 1: Logging into the Server

Log in to your server using SSH. If you're on Windows, you can utilize software such as PuTTY for this purpose. On Linux or MacOS, you can use the terminal. The command to log in will look something like this:

ssh username@server_address

Step 2: Installing Java Runtime Environment

As Minecraft server is written in Java, the first step is to ensure you have JRE installed. You can do this by running the following commands:

sudo apt update
sudo apt install default-jre

After installation, verify that Java has been installed correctly using the java -version command.

Step 3: Creating a New Directory for the Minecraft Server

It's a good practice to keep your applications organized, so I recommend creating a new directory for the Minecraft server:

mkdir minecraft
cd minecraft

Step 4: Downloading Minecraft Server Software

Visit the official Minecraft website and find the section for downloading server software (https://www.minecraft.net/en-us/download/server). Copy the link to the latest version of the server. Then use the wget command to download the software into the created directory:

wget [DownloadLinkForServer]

Step 5: Running the Minecraft Server

After downloading the file, you can start the server using Java. The command will look something like this, replacing filename.jar with the actual name of the downloaded file:

java -Xmx1024M -Xms1024M -jar filename.jar nogui

On the first run, the server will create several configuration files and stop, prompting you to agree to the EULA (end-user license agreement). You can do this by opening the eula.txt file and changing eula=false to eula=true.

Step 6: Configuring Firewall and Port Forwarding

To allow players to access your server from the internet, you'll need to configure your server's firewall and, if using a router, set up port forwarding. On Ubuntu, you can do this using ufw (Uncomplicated Firewall), which is easy to use. The following command will allow access to the port typically used by Minecraft (25565):

sudo ufw allow 25565/tcp

If you have a router, you'll need to find the port forwarding option in its settings and add a rule for port 25565 directed to the IP address of your server. The exact procedure varies depending on the model and brand of your router, so I recommend consulting your device's manual or online resources specific to your model.

Step 7: Running Minecraft Server as a Service

To ensure that the Minecraft server starts automatically upon system startup, it's a good idea to set it up as a system service. Create a new systemd unit file:

sudo nano /etc/systemd/system/minecraft.service

Insert the following configuration into this file, remembering to replace user with your username and path/to/minecraft with the path to your Minecraft server:

[Unit]
Description=Minecraft Server
After=network.target

[Service]
User=user
Nice=1
KillMode=none
SuccessExitStatus=0 1
ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
WorkingDirectory=/path/to/minecraft
ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar /path/to/minecraft/filename.jar nogui
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save and close the file. Then enable and start the service:

sudo systemctl enable minecraft.service
sudo systemctl start minecraft.service

Your Minecraft server should now be running as a service and automatically start on system boot.

With this, the installation of a Minecraft server on a Linux server is complete. Connect to the server using the Minecraft client by entering the IP address or domain name of your server and enjoy playing the game with your friends!

This guide equips you to create and manage your own Minecraft server, allowing you to play the game according to your own rules and with full control over the gaming environment. Remember to regularly update your server and backup your worlds to ensure your Minecraft adventures are safe and enjoyable.