There is a point to this story, but it has temporarily escaped my mind...
Contact Me MyFaceBook MyLinkedIn MyGitHub MyTwitter

Install Minecraft Server

First, Install OpenJDK

Create a directory to store Minecraft

sudo mkdir /opt
cd /opt
sudo mkdir minecraft

Download Minecraft

cd /opt/minecraft

sudo wget https://launcher.mojang.com/v1/objects/f02f4473dbf152c23d7d484952121db0b36698cb/server.jar -O minecraft_server.1.16.3.jar

if [ -h minecraft_server.jar ]; then
    sudo rm -f minecraft_server.jar
fi

sudo ln -s minecraft_server.1.16.3.jar minecraft_server.jar

Start the server to generate all of the supporting files

cat > /tmp/eula.txt << EOF
eula=true
EOF
 
sudo mv /tmp/eula.txt /opt/minecraft/

cd /opt/minecraft
sudo chmod o+w /opt/minecraft
java -Xms1024M -Xmx1024M -jar minecraft_server.jar nogui
# After the server startup is "done", stop the server by pressing Ctrl-C
sudo chmod o-w /opt/minecraft

Create a user for Minecraft to run under

sudo useradd minecraft

Make sure that the minecraft user owns all of the files…

sudo chown -R minecraft:minecraft /opt/minecraft

I also like to have plugins on my server so I use Spigot:

cd /tmp
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
 
java -jar BuildTools.jar --rev 1.16.3
java -jar BuildTools.jar --rev 1.16.3 --compile craftbukkit
 
sudo mv craftbukkit-1.16.3.jar spigot-1.16.3.jar /opt/minecraft/
 
cd /opt/minecraft
 
if [ -h spigot.jar ]; then
    sudo rm -f spigot.jar
fi
 
sudo ln -s spigot-1.16.3.jar spigot.jar
 
if [ -h craftbukkit.jar ]; then
    sudo rm -f craftbukkit.jar
fi
 
sudo ln -s craftbukkit-1.16.3.jar craftbukkit.jar 

Plugins

cd /opt/minecraft/plugins
 
#----------------------------------------------------
 
sudo rm worldedit-bukkit-*.jar
sudo wget https://media.forgecdn.net/files/2869/453/worldedit-bukkit-7.1.0.jar
 
sudo rm worldguard-*.jar
sudo wget https://media.forgecdn.net/files/2855/477/worldguard-bukkit-7.0.2.jar
 
sudo rm Multiverse-Core-*.jar
sudo wget https://media.forgecdn.net/files/2768/599/Multiverse-Core-4.1.0.jar
 
sudo rm Multiverse-Portals-*.jar
sudo wget https://media.forgecdn.net/files/2768/601/Multiverse-Portals-4.1.0.jar
 
sudo rm LaggRemover-*.jar
sudo wget https://media.forgecdn.net/files/2744/510/LaggRemover-2.0.6.jar
 
sudo rm AutoSaveWorld.jar
sudo wget https://media.forgecdn.net/files/2365/294/AutoSaveWorld.jar

Configure a startup script

cat > /tmp/minecraft.service << EOF
[Unit]
Description=Minecraft Server
Documentation=

Wants=network.target
After=network.target

[Service]
User=minecraft
Group=minecraft
KillMode=process
SuccessExitStatus=0 1 143

ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
PrivateTmp=true
ReadWriteDirectories=/opt/minecraft
WorkingDirectory=/opt/minecraft
ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

[Install]
WantedBy=multi-user.target
EOF

sudo mv /tmp/minecraft.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/minecraft.service

sudo systemctl enable minecraft.service

Start Minecraft Service

sudo service minecraft start
Copyright © 2022 by Julian Easterling. SOME RIGHTS RESERVED.
Privacy Policy              Terms of Use             


Creative Commons License
Except where otherwise noted, content on this site is
licensed under a Creative Common Attribution-Share Alike 4.0 International License.


All of the opinions expressed on this website are those of Julian Easterling and
do not represent the views of any of my current and previous clients or employers in any way.

If you notice an error on the site or content that has not been properly attributed, bring
it to my attention using the contact page and I will endeavor to fix it as soon as I can.

I accept no responsibility or liability for any damages incurred by following any of
my advice or by using any of the information on my site or of those sites that I link to.