# Install dependencies
sudo yum install -y java-1.8.0-openjdk screen
# Create a new unprivileged user for minecraft
useradd -r -m -d /opt/minecraft minecraft
# Create the directory that will house our minecraft instances
sudo su --shell /bin/bash minecraft
mkdir instances
exit
# Copy the [email protected] file into the correct place.
sudo vi /etc/systemd/system/[email protected]
# Reload systemd units
sudo systemctl daemon-reload
# Sudo into the minecraft user's shell
sudo su --shell /bin/bash minecraft
# Move into the instances directory
cd instances
# Create a new folder to house your instance
mkdir server1
# Install your minecraft instance, and make sure there is a minecraft_server.jar file.
# If you use Forge servers, you can use the following:
ln -s forge*.jar minecraft_server.jar
# Start and enable (start after boot) the server.
sudo systemctl start minecraft@server1
sudo systemctl enable minecraft@server1
I'm using
systemd
+screen
to launch a different application (similar in concept to launching a Minecraft server) so I tried to adapt things to my own purposes. This was not easy, but I've encountered the same issue as @Aviatorpaal and had to useType=forking
as well. There were also some slight differences in the parameters sent toscreen
, some of them not obvious. Ultimately, I got my own setup working using the skeleton framework suggestion posted on the Unix StackExchange (see point 2.), which worked quite well for me. It should also work fine for Minecraft or any kind of interactive server application that benefits from having a console.