Running your own server and saving cash is easier than you might think! In this guide, we’ll go over how to install Spigot server on an OVH VPS which is one of the best server deals for Minecraft hands down.
At the time of writing (February 2018) you can grab an OVH VPS SSD with 8GB of RAM for under $14 a month. You’ll be hard pressed to find a Minecraft host offering more resources for less cash; indeed many Minecraft hosts use OVH as their own platform.
The third tier server also comes with 40GB of fast SSD disk space and two reasonably fast CPU cores – both plenty for a modest server. Your mileage will vary based on your own players and their activities. Personally, I’ve found the third tier OVH VPS more than plenty for 5-10 players and it could probably handle more.
Before we begin, a quick guide on code. Through the tutorial when you need to enter a command or code precisely, we will
list it in this format
When you see anything written like that, that’s exactly what you need to enter. Don’t add any extra characters, not even spaces, unless the instructions say otherwise. Let’s get started then…
Purchasing an OVH VPS
First we’ll need to but the VPS from OVH over at https://www.ovh.com/world/vps/vps-ssd.xml – as noted above my preference is to go with the tier three VPS. If you like you can certainly go with the first or second tier and upgrade as needed.
You’ll also want to select a server location that matches most of your player base. If your player base will be mainly North America, the North America > Beauharnois (CA) option is the best. From personal experience I’ve found this offers good performance for both West and East coast players.
You’ll see I’ve selected Ubuntu 16.04 in the above screen shot, this is my personal preference, but other Linux distributions are fine. For what it’s worth Ubuntu 16.04 will receive maintenance updates into 2021. After this screen you’ll be asked to confirm your payment period and either login or signup to OVH.
One word of caution here if you’re creating a new OVH account. When choosing a password, the longer the password the better. You can of course use a mix of upper and lower case characters and weird symbols, but the password length is the most important when it comes to overall security. Shoot for something in the region of 20 characters or longer and avoid common words or repetitions. Try to make the password unique just for this single login. Minecraft servers can be the target of hackers, and if you’re OVH login is insecure, they can wreak the ultimate damage.
Logging in as admin
Usually within an hour of making your payment, you will get an email from OVH with “Your VPS installation” in the subject. This email will contain your admin username, password and IP (IPv4) address. Once you receive this, you’re good to go. Next you will need an SSH program such as Putty for Windows or Terminal on Mac (included as standard). Fire up the program and you will be asked for the connection details in your OVH email.
The first thing is to make sure installation of all the software on the server is upto date. The following command will check for the latest software updates.
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
This could take some time depending on how much software needs updating on your VPS. You might also be asked to confirm the process a few times by hitting y and pressing return.
Next you will want to install Java on the server, specially you will need the older Java 8 runtime. You can do that with this command:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
If that runs correctly, to make sure Java is setup you can use the command
and something like the following should be returned, confirming Java is now installed:
openjdk version “1.8.0_151”
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
Finally we want to create a new user. For security reasons we want to limit being logged into the server as admin, so this new user will be where we do most of the work of installing the Spigot server, running it and configuring it. We only ever want to log back into the admin user if we really really have to; e.g. backing up the server, keeping the software and OS upto date. So the next command to run is:
You can actually use any username you like, it doesn’t have to be minecraft. Replace that as you see fit but keep it simple and keep it lowercase. Once you run the command you’ll be asked a series of questions about the user such as:
Full Name :
Room Number :
Work Phone :
Home Phone :
Feel free to just press return to skip the ones you don’t want to bother with. The only one you MUST complete is the password option. Again, follow the password rules as above to keep your server secure. Also make sure the password is reasonably different to your admin password. You don’t want an attacker to be able to crack one password and use that to crack another in turn.
With the new user created you will want to logout of the admin SSH session. Simply enter
and your SSH session as admin will be terminated.
Logging in as your new user
The two commands to run are:
This will create a new directory called buildtools and move into the directory (cd is change directory). Into this we’re going to download the software to build the spigot server. To do that run this command:
That should only take a second or two to download. Remember you server at OVH is connected to the Internet at 100mbps. With the tools downloaded we want to run the following command. This could take some time, maybe go make a cup of tea:
java -jar BuildTools.jar --rev latest
With the command entered, the build process will start. That little –rev latest flag on the end will ensure the latest stable version of the Spigot software is created for you. If you need an older version for some reason you can enter different rev flags (e.g. java -jar BuildTools.jar –rev 1.8 for Minecraft 1.8). Checkout the Spigot site for more detailed info on the build tools and versions.
The build process might might take a while, so kick back and relax for a few minutes. Once the lines of scrolling information stop and the command prompt returns, enter the following three commands one after the other:
This will take you out of the buildtools directory and also create a new directory called server, for, yep you guessed it – your Minecraft server. The last command takes you into the server directory. Next enter the following command:
mv ../buildtools/spigot.jar spigot.jar
This will copy (mv is the command for move) the Spigot server software out of the buildtools directory into the server directory. Next up we need to start the Spigot server for the first time, with the following command:
java -Xms512M -Xmx512M -jar spigot.jar
This will start the server for the first time using 512MB of memory. Don’t worry it will error out pretty quickly as follows:
Loading libraries, please wait...
[16:33:52 INFO]: Starting minecraft server version 1.12.2
[16:33:52 WARN]: To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar"
[16:33:52 INFO]: Loading properties
[16:33:52 WARN]: server.properties does not exist
[16:33:52 INFO]: Generating new properties file
[16:33:52 WARN]: Failed to load eula.txt
[16:33:52 INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
It will in turn generate some more files we need to work on (you can use command “ls -l” to see the files now in the directory). Specifically, we need to accept the games EULA before the server can run properly. Enter the following command:
This will open the eula.txt file in the nano file editor. There are a few other editor tools you can use, but this is the one I use normally. With the file open, use your arrow keys to move the cursor to the eula=false section. Delete false, in its place write true. Next you can save the file by using “CTRL-O” (the letter not the number) and “CTRL-X” to exit the editor. At the bottom of the window you will see the various key combinations to use in the editor too.
Writing a bash script
Huh? Don’t worry, we’re almost there! In this last section we’re going to write a mini program of sorts. This will start the game up, and constantly loop over and over to check it is still running. If it fails, it will restart the Spigot server after five seconds. Spigot is pretty stable, but if something does go wrong, you don’t want your players waking you at 3 a.m. for a reboot!
First up lets use nano again, this time to create a file called startup.sh:
That will load a blank file as it doesn’t yet exist, into this file enter the following. Don’t copy and paste in one big block or you might add extra spaces at the end of each line, and the file won’t work.
java -Xms6G -Xmx6G -jar spigot.jar
echo -n "Server crashed at " >> /home/minecraft/server/crashlog
date >> /home/minecraft/server/crashlog
Again you will need to save and exit by using CTRL-O and CTRL-X.
If the user you created earlier is named other than minecraft, you will need to replace that in the above code. While that code might look daunting it’s pretty simple stuff. The server is spigot.jar (server software) is instructed to startup using 6GB of RAM, no more no less. From there it keeps looping unless the game crashes. If it does it writes the error output to a file called crashlog you can view for info later. If it does crash there’s a five second wait, and the whole thing loads up again.
Lastly we need to make this file executable (allowed to run) with the following command:
chmod +x /home/minecraft/server/startup.sh
And that’s largely it! We’re ready to run the game believe it or not!.
Starting up the Minecraft server in Screen
We could just run:
java -Xms6G -Xmx6G -jar -spigot.jar
at this point to start the game up, but as soon you close down your SSH window, the game would stop. That’s no good at all. We want to start the game in a Screen – think of this as a virtual, well, Screen, running on your server. You can close your SSH session into the server, but the screen you started up will still be there, running your game. When you SSH back into your server, you can also access that Screen again too.
screen -dmS spigot /home/minecraft/server/startup.sh
Nothing will immediately happen as the “d” flag in that code tells screen to detach and run in the background. To see what’s going and resume your Screen session you will need to enter:
You should now see the direct output of the game server. If you rejoined fast enough you will have seen endless lines of startup info fly by, everything from setting up spawn to configuring the world. Eventually that will stop and you will be left with a command prompt. Remember that while you have this Screen up, any commands you now enter are into the game server itself. E.g. you can run commands like “op player name” to give someone op status, or maybe “set time 1000” to set the time of day in the game.
You can now safely close your SSH window and walk away for as long as you want. The Screen you setup for the Spigot server will run and run by itself, restarting automagically if it fails for any reason. When you’re ready to come back and admin the server, just SSH into your OVH VPS and use screen -r to resume your Screen session as if you never left.
And that’s it, now you have a Spigot Minecraft server! Go ahead and connect to your game now in the Minecraft client, just use your IP address for the server as the address to connect to.
Setting up a Minecraft server in ten steps
O.k. while all that might seem daunting for someone new to server management under Linux, it’s actually really simple, and in truth should take you no more than 15-30 minutes depending mainly on the build time. The process can be be distilled down to seven steps really:
1) Purchase your VPS server
2) Make sure the VPS software is upto date
3) Create a user for the Minecraft server to run under
4) Download and build Spigot under that user
6) Agree to the Minecraft EULA
7) Write a mini script to start and monitor the game
And that’s really it!
Some useful Linux command basics
You might find the following commands handy when managing your server:
Print working directory. This will tell you what directory you are currently in, and the full path to it.
shows the contents of the current directory you are in.
change directory. Followed by a directory name, you will step down into this lower directory. Followed by two periods “cd ..” you will step back up a directory level.
shows a list of all the current Screens running and their names.
Optimizing the JVM for Minecraft
If you’re looking to optimize your server for every last drop of performance, you’ll need to get a little more fancy with the Java startup flags. The following are the defacto flags you should use, courtesy of the amazingly talented Aikaradora:
java -Xms6G -Xmx6G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar spigot.jar
If you wonder what all that means…very simply put, Java is designed so that each application can use its own set of optimizations, specific to the application in question. The flags above tweak the Java Virtual Machine to run Minecraft in the best possible way; primarily this means minimizing how much the Java Garbage Collection process impacts the in game experience.
For more details I recommend you read Aikaradora’s site in detail: