Install OpenJDK 23.0.1
Official download site for OpenJDK: OpenJDK JDK 23.0.1 GA Release
# sudo su
# wget https://download.java.net/java/GA/jdk23.0.1/c28985cbf10d4e648e4004050f8781aa/11/GPL/openjdk-23.0.1_linux-x64_bin.tar.gz
# tar -xvf openjdk-23.0.1_linux-x64_bin.tar.gz -C /usr/local/
# update-alternatives --install /usr/bin/java java /usr/local/jdk-23.0.1/bin/java 1
# update-alternatives --list java
# update-alternatives --config java
Create user for minecraft
Good password generator: https://1password.com/password-generator
useradd --create-home --shell /bin/bash --password iQ0ia32fjdhxEKUckkKs mcserver
Install Minecraft Server and Spigot
Minecraft Server Download Link: Minecraft Server Download | Minecraft
Spigot Download Link: BuildTools [Jenkins]
# mkdir /home/mcserver/minecraft
# cd /home/mcserver/minecraft
# vi buildspigot.sh
#!/bin/bash
version=1.21.4
rm ./server.jar
rm ./spigot-*.jar
mkdir ./make-spigot; cd ./make-spigot
wget https://piston-data.mojang.com/v1/objects/4707d00eb834b446575d89a61a11b5d548d8c001/server.jar
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev $version
mv ./server.jar ../
mv ./spigot-*.jar ../
cd ..; rm -rf ./make-spigot
echo $version > ./version.txt
# chmod +x buildspigot.sh
# vi cleanbuildfiles.sh
#~/bin/bash
rm ./BuildTools.jar
rm -rf ./work
rm -rf ./Spigot
rm -rf ./CraftBukkit
rm -rf ./Bukkit
rm -rf ./BuildData
rm -rf ./apache-maven-3.6.0
# chmod +x cleanbuildfiles.sh
# vi resetperms.sh
#!/bin/bash
chown mcserver:mcserver -R ./
# chmod +x resetperms.sh
# vi startmc.sh
#!/bin/bash
#set location
cd /home/mcserver/minecraft
#get version
version=`cat version.txt`
#start game
java -Xmx2048M -Xms2048M -XX:ParallelGCThreads=2 -Dlog4j2.formatMsgNoLookups=true -jar spigot-$version.jar
# chmod +x startmc.sh
# ./buildspigot.sh
# java -jar server.jar
# vi eula.txt
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Wed Feb 06 01:57:26 UTC 2019
eula=true
# java -jar server.jar
op desertmoose706
/whitelist add desertmoose706
CTRL-C
# cat whitelist.json
# cat ops.json
Configure Daemon / Auto Start / First Time Run
# vi /etc/systemd/system/minecraft.service
[Unit]
Description=Minecraft Server
Wants=network.target
After=syslog.target network-online.target
[Service]
Type=simple
Restart=on-failure
RestartSec=10
StartLimitInterval=60s
StartLimitBurst=3
User=mcserver
ExecStart=/home/mcserver/minecraft/startmc.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s INT $MAINPID
[Install]
WantedBy=multi-user.target
# ./resetperms.sh
# systemctl daemon-reload
# systemctl enable minecraft
# systemctl status minecraft
Edit Server Properties / Enable whitelist
# vi server.properties
#Minecraft server properties
#Sat Jan 04 03:01:01 MST 2025
accepts-transfers=false
allow-flight=false
allow-nether=true
broadcast-console-to-ops=true
broadcast-rcon-to-ops=true
bug-report-link=
debug=false
difficulty=easy
enable-command-block=false
enable-jmx-monitoring=false
enable-query=false
enable-rcon=false
enable-status=true
enforce-secure-profile=true
enforce-whitelist=true
entity-broadcast-range-percentage=100
force-gamemode=false
function-permission-level=2
gamemode=survival
generate-structures=true
generator-settings={}
hardcore=false
hide-online-players=false
initial-disabled-packs=
initial-enabled-packs=vanilla
level-name=world
level-seed=
level-type=minecraft\:normal
log-ips=true
max-chained-neighbor-updates=1000000
max-players=20
max-tick-time=60000
max-world-size=29999984
motd=My Epic Minecraft Server
network-compression-threshold=256
online-mode=true
op-permission-level=4
pause-when-empty-seconds=60
player-idle-timeout=0
prevent-proxy-connections=false
pvp=true
query.port=25565
rate-limit=0
rcon.password=
rcon.port=25575
region-file-compression=deflate
require-resource-pack=false
resource-pack=
resource-pack-id=
resource-pack-prompt=
resource-pack-sha1=
server-ip=
server-port=25565
simulation-distance=10
spawn-animals=true
spawn-monsters=true
spawn-npcs=true
spawn-protection=16
sync-chunk-writes=true
text-filtering-config=
text-filtering-version=0
use-native-transport=true
view-distance=10
white-list=true
# systemctl start minecraft
# systemctl status minecraft
Expose Externally / Port Forward / NAT
This is critical for others to connect. Please understand that you are also exposing your internal systems to the outside world, even at a small scale with port 25565. This is your choice, just know what you’re doing here.
- Enable whitelist!!
- Expose externally for friends, port forwarding aka NAT, ONLY port 25565
- Dynamic DNS for dynamic IPs, vs static. Noip.com, Dynamic DNS Update Client for Linux. E.g. ASUS routers have it built in.