Installing your own Minecraft server (Spigot)

Introduction

One fairly common use of Linux VPS boxes is the running of Minecraft servers. In this tutorial, we will cover the basics of installing an optimised server, called Spigot, and getting automatic start-up on server boot.

 

Installing Java & Screen

The first step is to install Java. If you know you already have java installed, then you can skip this. Otherwise, run the following:

The majority of server distributions come with screen installed by default, but if not, you can run the following to install it:

Fetching Spigot

Then, navigate to the directory where you want your server to be. For the purposes of this, we will use /usr/local/minecraft_server

You first need to create the directory as below

Now it’s time to fetch the Spigot server file. You can find the different versions at http://ci.md-5.net/job/Spigot/ and you’ll need to find a stable build that corresponds to the minecraft version you want to use.

Once you’ve found this, copy the URL and run the following on the server:

This will save the file as spigot.jar.

Testing Server

Next, we need to decide how much RAM to allocate for the server. In general, 512MB is more than enough for a small server with few plugins. If you encounter issues with running out of memory, you can try running with more.
Hence to start the server, we would run:

You can adjust the 512M value as you wish.
You can now type “stop” to stop the server. Doing this all the time would require manual starting and stopping of the server, which isn’t ideal. Hence, we will add a script to /etc/init.d/ to handle this.

Making the server run on startup and stop on shutdown
Run the following to create the script:

And paste in the following:

Then make the file executable by running:

And finally add it to the startup and shutdown like so:

Hence, to start your minecraft server you can now run

To stop the server, run

It will also automatically shut down on server shutdown, but it’s better to do this yourself, as you can then be sure it has saved and that it will not hang, delaying the shutdown, which can cause problems with some hosts.
This script starts the server in a program called screen. This essentially creates another terminal window, so if you wish to check out the output from your server or enter a command, you need to type :

You can then disconnect from this by pressing Control-A then Control-D and safely log out – the server will continue running in the background.

If you can’t connect and you have iptables set up you may need to run the following:

 

3 comments for “Installing your own Minecraft server (Spigot)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.