Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Set Up Your Minecraft Server on Debian or Ubuntu OS

DZone's Guide to

How to Set Up Your Minecraft Server on Debian or Ubuntu OS

Chekc out how to install a server for one of the world's most popular video games on your open source operating system here.

Free Resource

DON’T STRESS! Assess your OSS. Get your free code scanner from FlexeraFlexNet Code Aware scans Java, NuGet, and NPM packages.

Minecraft is one of the most-played games worldwide. Minecraft is a very popular game with more than 100 million users from all over the world. In a 3D-generated environment, players explore and build anything that they want. You can play as a single player or your friends can join your server in multiplayer mode.

To set up your own Minecraft server on Debian or Ubuntu, follow the tutorial below. This tutorial is compatible with The World of Color release 1.12.

Note: This guide is tested for Ubuntu 16.04 LTS & Debian 8.

Prerequisites:

  • You must have Alibaba Cloud Elastic Compute Service (ECS). To get free $300 credits in your Alibaba Cloud account, click here.
  • You must have a version of the game client to use your Minecraft server.
  • You should set up your server’s hostname.
  • Follow the general instructions to secure your server e.g. activating firewalls.

Minimum Requirements for these settings:

  • Ubuntu 16.04 installed or Debian 8 installed on server
  • 2GB RAM required (4GB Recommended)
  • Fast Internet (Provided with every ECS on Alibaba Cloud)

Before You Begin:

Before you begin installation of Minecraft on your server, you will have to follow steps below:

  • Login as root user with your root username & password via SSH client (e.g. Putty) or VNC console available in your Alibaba Cloud account dashboard.
  • You will have to update & upgrade your Debian or Ubuntu to latest packages using the following commands:
  •  # sudo apt update && sudo apt upgrade 

    Image title

    Select “install the package maintainer’s version” option and then select OK.

    Image title

    • Now you have to set up Java JDK environment & GNU Screen. For this, install OpenJDK & GNU Screen Package. OpenJDK is an open source available implementation of Java.  

    Install GNU Screen Packages

    To install GNU Screen Packages in Debian or Ubuntu:

    • Update the packages using the following commands:

     # sudo apt-get update 

    Image title

     # sudo apt-get upgrade 

    Image title

  • Now install screen using the following commands:
  •  # sudo apt-get install screen 

    Image title


    Install OpenJDK:

    In Debian 8:

    Use the following command for installing OpenJDK with GNU Screen Package in Debian 8.

     # sudo apt install openjdk-8-jre-headless screen 

    Image title

    In Ubuntu 16.04:

    Use the following command for installing OpenJDK with GNU Screen Package in Ubuntu 16.04.

     # sudo apt install openjdk-8-jre-headless screen 

    Image title

    • Now you have to create a user with root privileges.

    In Debian:

    In Debian, sudo is not enabled by default. You have to install sudo first. Use the following command:

     # apt install sudo 

    Image title

    Now add user using the following command:

     # adduser minecraft 

    Image title


    Now give root privileges to the added user:

     # adduser minecraft sudo 

    Image title

    In Ubuntu:

    In Ubuntu, you don’t need to install sudo manually. Just add the user using the following command:

     # adduser Minecraft 

    Image title

    Now give root privileges to the added user:

     # adduser minecraft sudo 

    Image title

  • If you have activated firewalls, you will have to define a rule in Alibaba Cloud security group for your cloud server to add an exception for port 25565. By default, this port is blocked by the firewalls. 
  • To do this follow the given instructions in snapshots:

    Go to your Elastic Compute Service section:

    Image title

    Click on more button for the ECS you are making ready for Minecraft Server:

    Image title

    Click on Configure Rules:

    Image title

    Click on Quickly Create Rules:

    Image title

    Add the configurations as shown in the screenshot below & click OK.

    Image title


    Installation of Minecraft:

    • To install Minecraft, first logout from your “root” account by ending the SSH session in your SSH client that you are using (In my case, I used putty SSH client.).
    • Login back to via SSH client or VNC console available in your Alibaba Cloud account dashboard as user “minecraft” that we created with root privileges.
    • Now you have to download the latest version of the Minecraft Multiplayer Server from using the following command:

     # wget https://s3.amazonaws.com/Minecraft.Download/versions/1.12/minecraft_server.1.12.jar Image title

    Note: You can replace the above URL with latest release URL. You can check latest release from here.

  • Now you have to create a script to run your Minecraft Server. You can do this as below:
  • Open file using the command below:
  •  # sudo nano /home/minecraft/run.sh 

    Image title

    • Add the following lines in opened file.
    #!/bin/sh
    BINDER=$(dirname “$(readlink -fn “$0”)”)
    cd “$BINDIR”
    java -Xms1024M -Xmx1536M -jar minecraft_server.1.12.jar -o true
    

    Image title

    Note: Xmx & Xms are the flags that are used to define maximum and minimum RAM respectively that will be used by your Minecraft server. Above settings are recommended for Alibaba Cloud’s Elastic Compute Service (ECS) with 2GB RAM. If you have more available RAM, you can modify flag settings according to your desire.

  • Now Press “Ctrl+x”.
  • Now Press “Y”.
  • Now Press Enter Key to save the file.
  • Now make run.sh an executable file by using the following command:

  •  # sudo chmod +x /home/minecraft/run.sh 

    Image title

    Now Run Minecraft:

  • When you will run Minecraft server first time using the following command, EULA file will be created and it will exit from running state.

  •  # ./run.sh 

    Image title

    • Open eula.txt file using the following command:

     # sudo nano /home/minecraft/eula.txt 

    Image title

    • Now change the value of eulain opened file to “true”.
    • Now Press “Ctrl+x”.
    • Now Press “Y”.
    • Now Press Enter Key to save the file.
    • Now to ensure that your Minecraft Server runs without SSH connection, use the following command to execute run.sh within your GNU Screen session:
    • To disconnect yourself from server session without stopping the server, Press “Ctrl+a” & then press “d”. You can resume the screen session using command:

     # screen -r 

    Now Connect to your Minecraft Server:

    • Now open your Minecraft client and login. After logging in, select Multiplayer option.
    • Then select Add Server and enter your AliBaba Cloud Elastic Compute Service (ECS) instance IP address or domain name. Then select done.
    • Your server is available now for incoming connections. Select Join Server to connect to the server.

    Try FlexNet Code Aware Today! A free scan tool for developers. Scan Java, NuGet, and NPM packages for open source security and license compliance issues.

    Topics:
    minecraft ,server ,open source ,open source os ,ubuntu ,debian

    Opinions expressed by DZone contributors are their own.

    {{ parent.title || parent.header.title}}

    {{ parent.tldr }}

    {{ parent.urlSource.name }}