notes/Setting up a Minecraft server.md

31 lines
1.6 KiB
Markdown
Raw Normal View History

2023-07-23 14:20:03 +00:00
# Preamble
*This guide assumes some basic knowledge of Linux and package managers.*
2023-07-23 14:23:03 +00:00
At minimum, a minecraft server requires Java, the [minecraft server jar](https://www.minecraft.net/en-us/download/server) or an alternative server (spigot, lithium), and the ability to port forward and allow programs through your firewall.
2023-07-23 14:20:03 +00:00
2023-07-23 14:19:03 +00:00
# Installing Java
2023-07-23 14:30:03 +00:00
As of 2023-07, Minecraft requires Java 17 to run version 1.20.1. You may need to look for a later version. Don't install the default version of Java in the repos of your chosen distro, it's very often out of date, and probably won't work with minecraft. You're going to look for any package that contains the JRE (Java Runtime Environment) or JDK (Java Development Kit). Both contain the Java Virtual Machine (JVM) and the ability to run Java programs. I like AdoptOpenJDK, but any distribution of Java that fits the version requirements will work sufficiently.
2023-07-23 14:31:03 +00:00
- Prior to installation, be sure to remove a java installation if it exists on your system. You can see if java is present on your distro with `java --version`.
2023-07-23 14:19:03 +00:00
2023-07-23 14:17:03 +00:00
2023-07-23 14:11:03 +00:00
This enables minecraft to run in the background, restart if it crashes, etc etc.
2023-07-23 14:12:03 +00:00
In `/etc/systemd/system`, place this file and tailor it to your liking.
```
[Unit]
Description=Minecraft Servre
2023-07-23 14:13:03 +00:00
# I don't know what these mean I'm getting them from here:
# https://gist.github.com/dotStart/ea0455714a0942474635
2023-07-23 14:12:03 +00:00
Wants=network-online.target
2023-07-23 14:13:03 +00:00
After=network-online.target
[Service]
# If wanted, you can set a particular group or user to run the service under
2023-07-23 14:14:03 +00:00
# User=foo
# Group=bar
# This command is run when the service is started
2023-07-23 14:17:03 +00:00
|ExecStart=/usr/bin/java -Xmx8G -Xms3g -jar /path/to/server.jar --nojline --noconsole
2023-07-23 14:12:03 +00:00
```