**NEW** How to Play Minecraft Java Mods on Windows
Building a full Linux modded server? See the Modded Linux server install documentation.
Building on Raspberry Pi? See the Raspberry Pi install documentation.
Minecraft Server Version: 1.13.2 - or 1.14.2 (See section 4c)
Oracle Java Version: 8u211
Approximate time to complete: 15 to 30 minutes depending on your server. This also depends on your comfort level working from the Linux command line. Give yourself plenty of time.
Get $100 in credit towards a dedicated server with DigitalOcean by using this link.
Step 1 - Download Java
Step 2 - Configure Java
Step 3 - Setup Your Environment
Step 4 - Install Minecraft
Step 5 - Configure your new Spigot Minecraft Server
Step 6 - Optional-- Configure Minecraft to start on bootup
Step 7 - Connect to Your Server
Step 8 - Hardening Your Minecraft Server if Visible on the Internet
Step 9 - Backup Your Server Frequently
Step 10 - Upgrading Your Minecraft Server
Step 11 - Recovering a Corrupted World
Step 12 - Creating Automatic Backups
Donate Your donations keep this site ad free -- Thank You
Report errors in this guide. Your feedback is appreciated.
This is a valid question. A fully managed solution like one offered by MCProhosting offers many benefits. There is no need to secure the underlying Linux OS, this is all done for you. You get a nice graphical front end to manage your server, automated backups, DNS management to access your server, FTP access. For smaller servers it is more cost effective as well as you can run a server for a dozen people on a $5/month server. I use fully hosted servers sometimes, they just make sense.
If you decide to go with a dedicated server you can get up to $100 in credit with DigitalOcean if you sign up through this referral link. A good starter setup is the $10 month server with 2GB of RAM and 50GB of SSD Disk.
Here are some of the reasons you may want to build your own;
1 - Maximum control right down to the OS level.
2 - Prefer working from the command line than from a Web browser to manage your server.
3 - High memory and cpu needs for your server and a VPS or dedicated server is cheaper than a higher end fully hosted solution.
4 - Have a server available which isn't costing you anything and a good internet link.
5 - Want to learn how to do it yourself from start to finish.
6 - Finally, the most important reason of all.....Because You Can!
Recommending a specific Linux distribution as "the best option" is like recommending a religion as the "best one to follow". You will either be preaching to the converted or alienating the person you are having the discussion with.
For my purposes I like using Debian and its derivitaves. Specifically I like Ubuntu Server and XUbuntu Desktop LTS versions. However I have used other distributions and have liked them as well. This guide uses Ubuntu Server 16.04 LTS using the apt package manager. When a package manager is called for, just substitute the relevant commands for your favorite distro. They are all good.
The instructions assume that you have root (Administrator) access to your server. For simplicity I assume you are logging in as the root user. All of these commands will also work with sudo. If running sudo from your user account then make sure to add it when necessary. I will not be using sudo in front of these command line arguments throughout the document.
Minecraft Server requires Oracle Java to run. You can install it on Debian or Ubuntu with apt but that will give you an older version. Instead, get the latest available directly from Oracle.
a) Login to your server via ssh or open a console window if this is a Linux Desktop system.
via Linux: ssh username@your_domain via Windows: Connect using a SSH client such as Putty
b) Download the latest version of Java (64bit) for X64 Linux and copy it to the /opt folder of your server.
Latest Version of Java
***NEW*** Oracle has changed the way they distribute their software. They have made things more difficult and now you need to login. There have also been changes to the license.
You will have to create a user login if you want to download the following file. jdk-8u211-linux-x64.tar.gz
Once downloaded copy it to your /opt folder and then unpack it;
tar -zxvf jdk-8u211-linux-x64.tar.gz
a) The next step will be to setup the Java environment so that your system recognizes how to access both the java binary and java compiler which will be required when building your minecraft server.
update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_211/bin/java 1 update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_211/bin/javac 1b) Make sure you set this version of java (and the compiler) as your default versions. These commands will give you a list of versions to select, just select the right version option. If this is the only version on your server then it will tell you so and select that one automatically. Do the same for the java compiler (javac).
update-alternatives --config java update-alternatives --config javacc) Finally check your version to make sure you are using the right one
i) java -version You should see the following; java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b09, mixed mode) ii) javac -version You should see the following; javac 1.8.0_211
a) remove the link
update-alternatives --remove "java" "/opt/jdk1.8.0_121/bin/java" update-alternatives --remove "javac" "/opt/jdk1.8.0_121/bin/javac"b) remove the folder (be careful whenever using rm -r -f, a misplaced "/" or "*" could/will mess up your system)
cd /opt rm -r -f jdk1.8.0_121
apt update && apt -y upgradeb) Install git
apt install gitc) Install screen (This will be needed to run your minecraft server console while logged out of your Linux server).
apt install screen
a) create the folder
cd /opt mkdir minecraft cd minecraftb) download the buildtools
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jarc) build the server
java -jar BuildTools.jar --rev 1.13.2 You can also now build version 1.14.2 (pillager update). You should do this on new worlds only while it is a development release. At the very least, if upgrading an existing world, do a full backup. Simply substitute 1.14.2 everywhere you see 1.13.2Depending on the power of your system this could go quickly or take a while. Be patient and come back in a bit. If all goes well you will have a file called spigot-1.13.2.jar (or whatever the latest version is at the time) in your minecraft folder.
If you have any trouble building the jar file I have made one available for download.
java -Xms1024M -Xmx2048M -jar /opt/minecraft/spigot-1.13.2.jar nogui*Note: -Xms1024M and -Xmx2048M are parameters telling java to start with 1GB of ram as a minimum for the spigot jar file and let it grow to 2GB max as needed. If your server has more ram to dedicate then you can adjust these numbers. More players and more mods mean you need more. These are not constructs unique to Minecraft. Do a google search on (xms xmx jvm) and you will get some good information on how to manage a JVM's heap. From there you can make a better determination on what you should set this to for your servers resources and how you will be using your server.
For example, on a Raspberry Pi with 1GB of ram I have set xms and xmx to 512M and 1008M respectively. So start the JVM with 512MB of ram and let it grow to just under 1GB max.
Finally, make sure to enter the right version that you have built. At the time of this writing Minecraft 1.13.2 was the latest version.
b) accept the EULA. The first time you try to run your minecraft server you will be required to accept the EULA.
nano eula.txtc) Change the following line to true and save the file
eula=trued) Run the server a second time to generate your world. World generation will take a while the first time. Subsequent server starts will be much quicker.
nano server.properties change the following line with your preferred seed directly after the = sign level-seed= If you leave it blank Minecraft will generate a random world on first launchOn a low power system you can lower the view distance. Start with 10 and adjust it downward if you get some lag. If you have plenty of CPU and RAM you can increase it as well.
java -Xms1024M -Xmx2048M -jar /opt/minecraft/spigot-1.13.2.jar noguie) make things a little easier on yourself by using a script to start minecraft
cd /opt && mkdir scripts cd scripts nano minecraft.shf) Copy and paste the following in your minecraft.sh file
#!/bin/bash cd /opt/minecraft/ && java -Xms1024M -Xmx2048M -jar /opt/minecraft/spigot-1.13.2.jar noguig) Save the file and make it executable
chmod +x minecraft.shh) Start your server
screen <---hit enter at the informational message /opt/scripts/minecraft.sh To exit the screen session hit 'CTRL AD'
nano /etc/rc.localRight before the last line 'exit 0' add the following command, save and exit the file. This will allow the minecraft server to start in a detached screen session when the server boots up.
screen -dm -S minecraft /opt/scripts/minecraft.sh
cd /etc nano rc.localin the rc.local file copy and paste the following
#!/bin/sh screen -dm -S minecraft /opt/scripts/minecraft.sh exit 0Save the file and make it executable
chmod +x rc.local
If that doesn't work you may have to re-enable the rc.local service. Use the following set of instructions. However this should not be necessary.
b) To access your console after bootup use the following command;
screen -r minecraft To exit the screen session use the following command CTRL AD
Note: Some people may question why I am using rc.local instead of an init script to start the minecraft server. I don't want to run the server in the background, I want a full screen session accessible to view and interact with the minecraft server console. If I want to stop the server I want to issue a stop command there, not from a script in init.d. Also rc.local is one line and is super easy. It just works well for this situation. I use init scripts for other things and they are great, but this is just a preference I have for a minecraft server. Do what works for you.
b) Click the Add Server button
c) Edit the Server Info as follows (insert the IP address of your Linux server)
d) Enter your world for the first time and have fun!!!
a) If you are installing this on a VPS or dedicated server you will most likely want to enable the firewall with netfilter/iptables. You should be blocking ports that are not used or that you do not want to expose to the internet. An example rule for a minecraft server would be as follows;
/sbin/iptables -A INPUT -p tcp --dport 25565 -m state --state NEW -j ACCEPTThis rule says to accept all new tcp packet requests to the minecraft server listening on port 25565.
To help you get started please refer to my article on setting up The Linux Five Minute Firewall.
Note:If you are not comfortable doing this then a VPS or dedicated server solution may not be a good one for you. If you manage a full Linux server connected directly to the internet with a public IP address, it is your responsibility to ensure you are hardening and securing it properly. If this is not something you want to do then a managed solution with a minecraft server hosting company like MCProhosting may be a better option for you. They take care of all the dirty work like this.
b) Activate whitelisting. It is extremely important to activate whitelisting if your server is visible on the internet. Port 25565
is a popular port and is actively scanned by all kinds of people using automated scripts.
They are looking for open servers so they can login and cause havoc on your world. Whitelisting will stop
unauthorized users from joining your world.
In your server.properties set the following value to true;
white-list=true Restart your minecraft server and run the following command at the console for each user you would like to allow. whitelist add minecraft_user1 whitelist add minecraft_user2 To remove a user whitelist remove minecraft_user2When an unauthorized user tries to connect to your server they will simply get a message that they are not whitelisted and will be turned away.
login to your server cd /opt tar -zcvf minecraft_backup.tar.gz minecraftCopy the minecraft_backup.tar.gz to a safe location, preferably another computer. This file can be used to restore your world if needed. Get into the habit of doing this regularly. You can even use the cron scheduler to automate the process at a specified time each day as explained in Step 12.
You've done it. You have successfully built your Minecraft Server. Of course Mojang will release a new version the very next day and all your friends will complain that they can no longer connect. No problem, upgrading your server to the latest version couldn't be easier.
a) First thing you need to do is backup your world. Just like in Step 9 we will do the following;
login to your server and stop your minecraft server. In the minecraft console type 'stop' and hit enter. cd /opt tar -zcvf minecraft_backup_version1.13.2.tar.gz minecraftb) download the latest buildtools
cd /opt/minecraft wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar -O BuildTools.jarc) build the new server. If all goes well you should see a new spigot jar file.
java -jar BuildTools.jar --rev 1.13.x (use --rev latest for the latest spigot version)Compiling your own is better, but I do make jar files that I have compiled available if needed. Files are signed with my gpg key and have a SHA256 hash that you can use to verify the integrity of the file.
jar file download
d) Update your minecraft.sh startup script to use the latest jar file
cd /opt/scripts nano minecraft.sh Update the command to start the new jar file cd /opt/minecraft/ && java -Xms1024M -Xmx2048M -jar /opt/minecraft/spigot-1.13.2.jar nogui Save the filee) Restart your server by either running your startup script or reboot your Linux server if you configured it to start on boot.
If you did your backups like we discussed in Step 9 then you are laughing. To restore your previous backup do the following;
Delete your existing minecraft folder cd /opt rm -r -f minecraft copy your previously saved minecraft.tar.gz file to your /opt folder. restore your world tar -zxvf minecraft.tar.gzThat's it, restart your server and you have successfully restored from your last good backup. Any changes you made since that backup are gone, so it is important to do your backups regularly.
1) Provide a ready to use script to initiate the backup
2) Configure the cron scheduler to start the backup at 2:02am everyday
3) Name the backup day_of_week-minecraft-.tar.gz
This will create a 7 day rotation of backups with the oldest being overwritten with a new one.
a) Create your script.
cd /opt/scripts nano mcbackup.shb) copy and paste this script into your mcbackup.sh file you have open in the nano editor. Change the dest= line to point to the folder you want your backups to reside in.
#!/bin/sh #################################### # # Backup minecraft world to a # specified folder. # #################################### # What to backup. Name of minecraft folder in /opt backup_files="minecraft" # Specify which directory to backup to. # Make sure you have enough space to hold 7 days of backups. This # can be on the server itself, to an external hard drive or mounted network share. # Warning: minecraft worlds can get fairly large so choose your backup destination accordingly. dest="/home/username/minecraftbackups" # Create backup archive filename. day=$(date +%A) archive_file="$day-$backup_files-.tar.gz" # Backup the files using tar. cd /opt && tar zcvf $dest/$archive_file $backup_files
c) Save the file by pressing CTRL-X and entering Y
d) Make the file executable
chmod +x mcbackup.she) Test your script. Before creating the scheduled task ensure your script works
/opt/scripts/mcbackup.shYou should see the backup happening. Once completed open the file it created which should be in the location that you specified. Once you have confirmed that your backup works, create a scheduled task to automate the backups.
f) Create a scheduled task with the cron scheduler
Make sure you are logged in as root so that it writes to your root user crontab.
crontab -eEnter this line at the end of your root crontab and then save it.
02 2 * * * /opt/scripts/mcbackup.sh &> /dev/nullThis will create your backup every day at 2:02 am. That's it, in your folder where you specified your backups to be created you will have the following after one week;
Monday-mcbackup-.tar.gz Tuesday-mcbackup-.tar.gz Wednesday-mcbackup-.tar.gz Thursday-mcbackup-.tar.gz Friday-mcbackup-.tar.gz Saturday-mcbackup-.tar.gz Sunday-mcbackup-.tar.gzEvery day your oldest file will be replaced with the new backup giving you a seven day rotation of backups.
That's it! Now have fun! I hope these instructions were helpful and that you learned a bit of how a Minecraft server functions.