Create a gist now

Instantly share code, notes, and snippets.

@vemacs /
Last active Apr 21, 2017

What would you like to do?
Instructions for setting up a Spigot server using mark2 on a fresh Ubuntu Server 14.04 LTS install.


  • a vswap OpenVZ VPS or a KVM/Xen/VMware VPS with Ubuntu Server 14.04 LTS installed (architecture doesn't matter), or a dedicated server
  • patience and a willingness to learn
  • approximately 10 minutes of time

Why Ubuntu LTS?

You can skip this section, but here's some reasoning as for why I chose Ubuntu LTS for this guide:

  • It combines the stability of Debian with support from the larger Ubuntu community
  • The "milestone" release cycle helps maintain stability and support
  • It has updated repositories and easy ways to install software not in them
  • It has enterprise support and is easy for newbies to understand
  • It has a sensible package manager (for installing software) and startup daemon
  • It's fast, has sensible defaults, and is easy to set up Minecraft on

Note: This guide should work for Debian 7.

Note 2: For securing CentOS, follow this guide. You need to install python-pip, which can be found in EPEL, and python-dev, which should be in the standard repos.

Accessing your server

Your host should have provided details for accessing your server via SSH.

  • On Windows, you can use the free Putty SSH client to access your server.
  • On a Unix-based OS (e.g. Mac OS X), you can use the SSH client in the terminal as such: ssh <server address> -l <username, should be root for clean setups> -p <port>

Fill in the details on your respective client, and start the SSH session. You might see something about "the authenticity of the server can't be established", that's normal, and just input "y" or "yes". Now, input the password your host gave you (you won't see it in the client, that's convention). You can paste using the right mouse button on Putty, and otherwise, it depends on your terminal.

If your host didn't give you a root account, (OVH sometimes does this), you can skip this and "securing your server".

Once you're inside, you should see the Ubuntu message of the day, and a line on the bottom saying:

root@<machine hostname>:~$ 

That is the shell you will be using, and let's get this party started.

Securing your server

The root account is the superuser of the system, and as such, you should not run non-administrative tasks using this account.

The first things we will be doing are:

  • updating your server to the latest packages
  • setting up a separate user account on your system for running your server
  • disabling the root account, and enabling escalation via sudo

To update your server, run the following two commands (press enter at each newline):

apt-get update
apt-get dist-upgrade

See, that wasn't too difficult. Next, we'll add an administrative user:

adduser <user name here>

For example, adduser minecraft. After you've set and verified the password, you don't need to put any more information. Just keep on hitting enter.

Next, we'll be adding the new user to the administrative users list:

usermod -a -G sudo <user name here>

Now, exit your SSH session by running exit, and follow "accessing your server", this time using the account you just created instead of root.

Once you've gotten into your new account, we need to test if it has root privileges. Run a sudo apt-get update, input your password, and see if it runs. If it runs, you're on the right track, otherwise, go back a few steps and check your work.

Let's change our SSH login settings. First, let's install nano, the text editor (if it isn't already installed):

sudo apt-get install nano

Run nano, and take a look. Ctrl+X, then Y + Enter closes and saves a file. A blank file isn't saved. Close nano, and read on.

Now, let's remove some annoyances of nano:

sudo nano /etc/nanorc

Change set historylog to #set historylog, and save the file: Ctrl + X, Y, and Enter. Next:

cd ~
sudo rm .nano_history

Now, we need to disable the root account, as we don't need it anymore, and it presents a security risk. Run sudo passwd -dl root, and now, we'll edit the SSHd configuration so that root can't log in either:

sudo nano /etc/ssh/sshd_config

Find the line that says "PermitRootLogin", and change that to no. Save the file, and then run:

sudo service ssh restart

You should preferably set up public key authentication for proper security, which is outside the scope of this tutorial. See this guide for more information on creating and using public keys.

Now, in case you don't like the spammy Ubuntu message of the day when you log in, you can do:

cd ~
touch .hushlogin

For future reference, ~ is your home directory (a.k.a. folder).

Setting up mark2

mark2 is a server wrapper with advanced monitoring, scripting, and multiuser capabilities that's point-and-click through the SSH session, and is easy to install on Ubuntu. Let's get started.

First of all, we need to install some dependencies:

sudo apt-get install python-dev libssl-dev python-pip git python-software-properties software-properties-common

We are done with the initial dependencies. Now, it's time to:

  • Clone the mark2 repository
  • Install mark2 requirements
  • Link mark2 to an executable so you can easily run it

This is pretty straightforward, and don't worry if you don't understand the commands:

sudo git clone git:// /usr/local/share/mark2
cd /usr/local/share/mark2
sudo ln -s /usr/local/share/mark2/mark2 /usr/local/bin/mark2
sudo pip install -r /usr/local/share/mark2/requirements.txt

Congratulations! You have now set up mark2. Finally, let's download and install our Minecraft server running Spigot.

Setting up Spigot

Obviously, we need to install Java first (we'll be installing Oracle Java 8):

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer oracle-java8-set-default

If you like your freedoms, or the Oracle installer isn't working for some reason, do:

sudo apt-get install openjdk-7-jre-headless

Next, let's get back to your home directory, and make a folder called spigot:

cd ~
mkdir spigot
cd spigot

Upload your spigot-xxx-SNAPSHOT.jar to this directory using your favorite SFTP/SCP client, or run the latest BuildTools on the server (only if your server has more than 1.5GB or so of RAM, otherwise run it locally and upload the JAR, or wget from a precompiled source (be careful)):

mkdir buildtools; cd buildtools
java -jar BuildTools.jar

Wait for that process to complete, and spigot.jar should be in the buildtools folder. Copy it to the spigot folder:

cd ..
cp buildtools/spigot*.jar spigot/

Now, let's set up a blank mark2 configuration, so we can start the server:

sudo mkdir /etc/mark2
sudo touch /etc/mark2/

It's easier to use our own instead of trawling thru the config.

We need to tell mark2 what to do, so:

cd spigot

Paste this into nano:
# Use whatever mark2 saved the JAR as here
# Saving notifications aren't really useful
# This helps stop GC hangs

Save the file, and now, let's start the server:

mark2 start

You should see mark2 starting the server, and congratulations, you have set up a server with mark2. Connect to your Minecraft server using your VPS' address, and bask in the glory of having set up a Minecraft server.

Accessing your Minecraft console

To access your Minecraft console, run mark2 attach. This is the standard mark2 console, and note that you can click on most things, and control the server that way.

Let's run some sample commands:


That gives you the Spigot version you're running. Now, run the following with the tilde to restart the MC server:


Now, exit mark2 by pressing Ctrl+C. You can reattach using mark2 attach. You can run either ~stop in the console or mark2 stop to stop the MC server. This works for multiple logged on users without any additional configuration, unlike screen or tmux.

If you have multiple servers, you can click the server names at the top of the mark2 screen to switch to one of them.

If you're getting special accented characters for mark2, you need to force your SSH client to use UTF-8 encoding.

For Putty, you can go to Window > Translation, and set "received data" to UTF-8. Restart Putty to see the changes.

Scripting mark2, and maintaining uptime

This will be the final "tutorial" component, and will cover:

  • Automatic restarts
  • Periodic saves
  • Starting mark2 automatically if your server restarts

mark2 has a powerful scripting mechanism. I recommend that you review it first before continuing, so that you gain a better understanding of the cron syntax used in mark2 and Linux in general.

Now, let's create the scripts.txt file:

cd ~
cd spigot
nano scripts.txt

Paste this in nano, and adjust as necessary:

     # Saves the map every 15 minutes
     */15 *    *    *    *    ~save
     # Restarts Spigot every 24 hours
     0    12   *    *    *    ~restart 5s

Save the file, and stop mark2 by running either mark2 stop or ~stop in the console. Start mark2 by running mark2 start.

If you wish to use Spigot's builtin /restart command, put

mark2 send -n ${PWD##*/} ~restart

in a file named in your spigot folder. Then, make it executable by running chmod +x Now, you can run /restart in-game to restart your server.

Now, in case you need to restart your VPS, let's set it up so that mark2 starts your server automatically:

sudo nano /etc/crontab

Add this to the end, obviously customizing your server location and username:

@reboot <username> mark2 start /home/<username>/spigot

Save the file, and that should be covered. If you really need to test it, you can attempt to restart the server:

sudo reboot

This covers the general server setup using mark2. Sit back, relax, eat a sandwich, and play some Minecraft.

Graphical access

In case you're not feeling like using wget and nano to download plugins and edit configs, or want to easily transfer your existing server, any SCP/SFTP client will do.

WinSCP is a good choice for Windows, CyberDuck works quite well on OS X, and Filezilla is a nice cross-platform solution.

For these clients, just select SCP or SFTP, and use your SSH credentials. Use their respective documentations for usage.

MySQL Server

Some plugins, such as Logblock, require an SQL server. Setting up a server that can be accessed only locally is as easy as:

sudo apt-get install mariadb-server

Input your preferred SQL password (preferably different from your server password), and we can create a database.

First, let's login to the MySQL shell:

mysql -u root -p

Type the password you set earlier, and now, inside the shell:

create database minecraft;

That created a database called minecraft, and exits the shell. SQL queries end with ;.

Now, to use that database in a plugin, fill in the host as localhost, username as root, password as the one you set during the install, and database as minecraft.

If you want to set up multiple SQL users, or access the database remotely, that is outside the scope of this tutorial. Please use Google for guides.

Tips and tricks

If you're migrating a server, and you can't connect after the migration, check that server-ip in is either blank or the IP you want it to bind to, and check your Votifier settings (this can cause connection failures).

If you really need a specific version of a JAR, or just want to download files directly, cd into the directory you want to download to, and then:

wget <file location> -O <output name>

You might need to sudo apt-get install wget, depending on your Ubuntu image.

For monitoring resource usage, you can run top, and for monitoring memory usage, you can run free -m.

Update your system using sudo apt-get update && sudo apt-get dist-upgrade. Update mark2 using cd /usr/local/share/mark2 && git pull.

Have fun!

Additional resources

You should review these sometime to learn more about Ubuntu, mark2, and Linux in general (assuming you already know how to administer Minecraft servers)

Some entertainment

<LaxWasHere> You could have just made a bash script. "Minecraft in 2 seconds."
<chiisana> 2 seconds* 
<chiisana> *: actual time may vary depending on internet connection speed, and server installation time
<vemacs> Coming soon?!

ghost commented Jun 24, 2013

Nice Guide

For a full gui experience you can always use x2go... But this is useful for the few people you op on the server XD

When I did "sudo pip install urwid feedparser psutil", i got error "sudo: pip: command not found". I was able to go ahead by doing "sudo apt-get install python-pip" first


vemacs commented Jul 29, 2013

Changed install instructions such that mark2 pulls in all dependencies.

this is a great tut and i love this system, previously used screen and i was wondering if there was a way to enable colours? it would make it easier for me to distinguish commands form players and the players ranks, ect


vemacs commented Sep 24, 2013

@MuttyDeath: Would have to pressure the mark2 devs for that. Work seems to have started again, so we may see that issue in the future.

RafaAro commented Dec 14, 2013

How could I add more ram to my server?


vemacs commented Dec 18, 2013

@RafaAro change the

RafaAro commented Dec 23, 2013

Good, Does this functions the same for BungeeCord Server?

how would this work with multiple servers? such as a bungeecord setup?>

Hey @vemacs thanks for this. I wanted to point out that this part:

# Use whatever mark2 saved the JAR as here

ended up having to be:

# Use whatever mark2 saved the JAR as here

through following everything else in the tutorial step by step. Might be something worth pointing out in case somebody isn't familiar with command line or configuration like this.


vemacs commented May 4, 2014

@Sonicrida, fixed

aaomidi commented May 29, 2014

If you're having problems with the command 'mark2 config'

Please use this issue to guide you to fix your file:


vemacs commented May 30, 2014

@aaomidi That's a pretty serious issue, will be revising guide accordingly.

Could this be written to show how to run more then one server on a machine?


vemacs commented Jul 15, 2014

@chamunks Just mark2 start a new server and mark2 attach -n <name>

Mark2 is officially abandoned...

gsand commented Nov 30, 2014

I'm maintaining an updated fork. It has bungeecord support and a few other changes.

@gsand will running the update command above update my mark2(by mcdevs) to your most recent version?
And thank you so dam much for taking up mark2 and for all the work!
And a big big thanks to vemacs for this tutorial too!!


vemacs commented Dec 14, 2014

To update to @gsand's fork, do:

cd /usr/local/share/mark2
sudo git remote set-url origin
sudo git fetch
sudo git reset --hard origin/master
sudo git branch --set-upstream-to=origin/master master

To update: cd /usr/local/share/mark2 and sudo git pull

@vemacs entering
"sudo git branch --set-upstream-to=origin/master master" shows

"error: unknown option `set-upstream-to=origin/master'"

love this. thank you sooo much! you saved me so much research. I'm bumping and linking this thread. lol

Just comming here to say that this tutorial is awesome and helped me alot :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment