To start off with we need to switch to our Minecraft profile that we created in the first section of this series.
Now we need to setup the respective files. The Minecraft server executable will do most of this for us, but there are a few files and directories that we need to add manually.
mkdir -p server/jars mkdir servers/backups
Next we need to get the Minecraft server
.jar file. The easiest way to do this id to use the Minecraft Launcher on our local machine.
Select the "Installations" tab and click on the installation that has the same version of Minecraft that you want your server to run. This is typically labeled as either "Latest release" or "Latest snapshot".
In the version section click the server button. This will download the server.jar file for that version of Minecraft.
Next, using the terminal on our local machine we want to copy the file onto our Linode server. Name this something descriptive--for instance, if I was downloading the server.jar file for Minecraft 1.15 I would name the file: "minecraft-server-11.5.jar".
scp ~/Downloads/minecraft-server-11.5.jar minecraft:server
This command will copy the file
~/Downloads/minecraft-server-11.5.jar to the ssh server with the hostname minecraft that we specified in out
~/.ssh/config previously. Specifically, it will copy the server.jar file into our
~/server/jars directory in our minecraft user account on the Linode server.
Now we can go to our minecraft users home directory on our Linode server.
To populate the server directory with the files needed to configure our Minecraft server we can issue the following commands:
java -jar minecraft-server-11.5.jar
You should be met with this message:
[11:47:16] [main/ERROR]: Unknown biome, defaulting to plains [11:47:16] [main/ERROR]: Failed to load properties from file: server.properties [11:47:16] [main/WARN]: Failed to load eula.txt [11:47:16] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
This means that the basic files you need to configure your server are present.
To start off with we need to agree to the EULA. There are rules to how you can use the Miencraft server files, and you have to agree to them before you can run your server. You can read over the rules here and then edit the
eula=true meaning that you agree to Mojang's Terms and Conditions.
The main configuration file for your minecraft server is called
server.properties you can learn more about this file on The Offical Minecraft Wiki
You can tweak this file to your liking, but there are a few lines that I recommend you change before moving forward.
spawn-protection=16: I recommend changing this to 0 if you are just playing with your friends, otherwise chests within a specific distance of spawn will be locked to other players.
enforce-whitelist=false: Change this to true so that only people you want on your server will be able to join.
server-ip=: set this to equal your server IP.
view-distance=10: I set this to 16 as I like to be able to see farther and there is a limited number of people playing on my server. If you change this setting you may experience extream lag when generating new terrain. See the server optimization section for more information.
motd=A Minecraft Server: This is the message that players will see in the multiplayer screen within Minecraft. Change it to whatever you like.
I have found a Github repo that has some really well written scripts that can be used to start your minecraft server. and run hourly backups of your servers world here.
We can download the scripts using the following commands from our servers directory:
wget https://raw.githubusercontent.com/BrandonDusseau/minecraft-scripts/master/startmc.sh wget https://raw.githubusercontent.com/BrandonDusseau/minecraft-scripts/master/backup.sh
Next we want to edit the
startmc.sh script. This script will be used to start our minecraft server.
Change the MCDIR to point to the root directory of our server:
Change the Java Runtime Arguments to utilize the 4 GB of RAM that we are paying
JVMARGS="-Xmx2048M -Xms3096M -d64"
Change the location of our jar file:
We then need to configure the
Change the root directory of our server:
Now we need to move our
.jar file to the correct location:
mv *.jar jars
The scripts need to be executed so we need to modify the file permissions
chmod +x backup.sh chmod +x startmc.sh
We want the backups to happen automatically, and the miencraft server to start up automatically upon system boot (that way if we update our server, or reboot for anyother reason, we do not have to manually start the minecraft server back up again).
We can do this by using
This will prompt you to select an editor, I choose 2 for
vim.basic but you can choose whichever you are most comfortable with.
Once you select your editor, we add the following lines to the file that was opened:
@reboot sleep 30 && /home/minecraft/server/startmc/sh 0 * * * * /home/minecraft/server/backup.sh
We can then start the server:
Congradulations your minecraft server is now running. However there are still a few things you need to do before you are finished setting it up.
You then need to connect to the
screen session to whitelist yourself, and give yourself admin privilages.
If the bottom line says "[done]" then you are welcome to issue miencraft server commands, if it does not say "[Done]" then just wait untill the server finishes loading.
To add uses to the whitelist:
whitelist add <user-name>
You can add your minecraft username and the username of any friends you want to be able to join your server. Note that once you make yourself an admin, these commands can be issued from within the game.
Admins are able to issue commands that modify the game, these are often refered to as cheats.
DO NOT MAKE ANYONE YOU DO NOT FULLY TRUST AN ADMIN
My recommendation is that you only make yourself an admin, so that you are in complete control of your minecraft server.
To make yourself an admin issue the following command:
You can now detach from the screen session by pressing
Ctrl+a d. Now you can close your ssh connection and your minecraft server will continue to run.