I’m just recording some notes here on the steps I took to run a Minecraft (Spigot) server on a CentOS 7 server.
Install Pre-requisites
yum install git python-twisted-core python-psutil python-urwid python-twisted-web screen
Get Java
You could try using OpenJDK with
yum install java-1.8.0-openjdk
Or
visit the Oracle website agree to the license agreement and download the jdk-8u131-linux-x64.rpm file. Copy that file to your server using SCP and install it with:
rpm -ivh jdk-8u131-linux-x64.rpm
Test that Java is installed and working by runing:
java -version
You should get positive results before moving on.
Get Spigot
Visit the downloads page for Spigot and download the BuildTools.jar file for the latest release.
On the server make sure you are the root user:
su - root
then create the directory for all your spigot files:
mkdir /opt/spigot
Then copy the BuildTools.jar file to the server/opt/spigot using SCP.
Run the build tool with:
git config --global --unset core.autocrlf
java -jar BuildTools.jar
The result should be similar to the screenshot below:
And this should create a file structure like the following:
Create a user to be used to run the spigot process:
useradd minecraft
And give that user permissions for the directory:
chown -R minecraft /opt/spigot
Screen
Screen is an alternative method to run the spigot process than using mark2. To use screen create a file
vi /opt/spigot/start.sh
and add the following to that file – you will need to amend the 1.12 text to point to the version of spigot that you have downloaded & built:
#!/bin/bash
cd /opt/spigot/
/usr/bin/screen -h 1024 -dmS minescreen /usr/bin/java -Xmx512M -Xms512M -jar /opt/spigot/spigot-1.12.jar
Make it executable:
chmod +x start.sh
Edit the eula.txt file and change the text to:
eula=true
Then run it as the minecraft user:
sudo -u minecraft /opt/spigot/start.sh
You can check that the process is running with:
ps -ef | grep spigot
And check that it is listening on the port:
ss -luntap | grep 25565
To re-attach to the screen:
screen -r minescreen
But if you run the spigot process as the minecraft user you will need to use:
sudo minecraft screen -r minescreen
When you are looking at the output from the spigot server you can detach from the screen session again with
Ctrl-A d
BungeeCord
BungeeCord allows running multiple minecraft servers from one machine.
Firewall
I use iptables on CentOS rather than the default firewalld. For iptables edit the config file:
vi /etc/sysconfig/iptables
add a line for port number
-A INPUT -p tcp -m state --state NEW -m tcp --dport 25565 -j ACCEPT
then restart the service:
systemctl restart iptables
Operations
While the server process is running you can connect using minecraft an ‘op’ a user with:
/op username
To elevate a user to an ‘op’ using the screen session :
sudo minecraft screen -r minescreen
op username
You can also ban players and IP addresses and much more.