You are here:

Host a Minecraft server on Ubuntu with Spigot/Bukkit

Host a Minecraft server on Ubuntu with Spigot/Bukkit

Introduction

Create a Minecraft server on Ubuntu with this tutorial.

Installation

To begin, update the Ubuntu operating system:

apt update && apt upgrade

After the completion of the update and upgrade command, your Ubuntu operating system is now up-to-date.

Next, let’s install the necessary packages to run a Minecraft server:

sudo apt-get install git openjdk-8-jre-headless -y

Download Spigot BuildTools to generate the required server files:

wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar

Now, let’s run the BuildTools script to make the server files. They’ll appear right where you are!

git config global unset core.autocrif

java -jar BuildTools.jar

We’re in the process of building the server files—this will take a few minutes.

Once done, let’s copy the server file to a new directory, say /etc/minecraftserver.

mkdir /etc/minecraftserver

cp spigot.jar /etc/minecraftserver/

We’ve got our Minecraft Server directory ready. Running the server file for the first time will generate all the necessary files.

Now, let’s craft a startup script!

cd /etc/minecraftserver
nano start.sh

 

Use the ‘nano’ command to open a text editor. With this editor, you can create a startup script. Simply paste the following code into the text editor:

           while true; do echo “Starting server now!”;

           java -Xms1G -Xmx1G -XX:+UseConcMarkSweepGC -jar spigot.jar

           echo “Server restarting in 5 seconds! Press control+c to stop!”; sleep 5; done;

Notice the -Xms1G and -Xmx1G? It designates 1GB of memory/RAM for the Minecraft Server. If your VPS has more memory/RAM, feel free to allocate more.

Save the file with CTRL + O and Enter, then exit with CTRL + X and Enter.

Now, execute the following command:

chmod +x start.sh

Lets start the Minecraft Server for the first time!

./start.sh

The Minecraft Server might not start correctly because we haven’t accepted the EULA yet. Edit the EULA file and change false to true.

nano eula.txt

Press CTRL + O and Enter to save the file Press CTRL + X and Enter to exit the file

Start the Minecraft Server again:

./start.sh

Your Minecraft Server is finishing up the map and configuration file generation. Once complete, you can connect to the server in-game!

To stop the Minecraft Server, use the following command:

stop

To ensure the Minecraft Server continues running after closing the SSH connection, start it in the background with the following command:

screen ./start.sh

You can safely close the SSH connection to your VPS, and the Minecraft Server will persist. When starting a new SSH connection to your VPS, use the following command to access the running Minecraft Server:

screen -r
Was this article helpful?
Dislike 0