Minecraft Server

Setting up a SpongeForge server
Debian Sponge Minecraft


  • Debian GNU/Linux 9 (stretch)
  • Forge 1.12.2 (build (click)


Installing Oracle Java JDK

Information mainly gathered from here. Specifically install Java 8, as almost if not all Minecraft servers and mods require this particular version.

apt-get install software-properties-common
add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
apt-get update
apt-get install oracle-java8-installer
update-alternatives --config java

## add to /etc/environment

# check
source /etc/environment

Installed mods

Mod Version Source
ActuallyAdditions 1.12.2-r137 click
BuildCraft 7.99.17 click
Chisel 1.12.2- click
CodeChicken Lib 1.12.2- click
Dynmap 2.6-beta-1 click
Extra Utilities 1.12-1.7.6 click
InventoryTweaks 1.63 click
JEI 1.12.2- click
JEI Integration 1.12.2- click
JourneyMap 1.12.2-5.5.2 click
NEI 1.12.2- click
SpongeForge 1.12.2-2705-7.1.0 click
Traverse 1.12.2-1.5.4-51 click

Interactive Map (Dynmap)

Visit http://www.tzerk.space/mcmap/

Apache2 reverse proxy entry (in /etc/apache2/site-available/<yourconf>.conf)

RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /mcmap/(.*)     ws://localhost:8123/$1  [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /mcmap/(.*)     http://localhost:8123/$1 [P,L]
ProxyPass /mcmap/ http://localhost:8123/
ProxyPassReverse /mcmap/ http://localhost:8123/

Administration Panel

Provided by the SpongeForge Plugin Web-API

Access http://www.tzerk.space/admin/

Apache2 reverse proxy entries (in /etc/apache2/site-available/<yourconf>.conf)

ProxyPass /admin/ http://localhost:8080/admin/

<Location /admin>
    AuthType Basic
    AuthName "Restricted Content"
    AuthBasicProvider file
    AuthUserFile "/<path>/.htpasswd"
    Require valid-user

RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /admin/(.*)     ws://localhost:8080/admin/$1  [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /admin/(.*)     http://localhost:8080/admin/$1 [P,L]

ProxyPassReverse /admin/ http://localhost:8080/admin/
ProxyPass /api/ http://localhost:8080/api/
ProxyPassReverse /api/ http://localhost:8080/api/

Add the following to /etc/apache2/site-available/000-default.conf to enable .htaccess

<Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted

Minecraft Server as a systemd service

Create a new user

groupadd -r minecraft
useradd -r -g minecraft -d "/home/minecraft" -s "/bin/bash" minecraft

File /etc/systemd/system/minecraft.service

Description=Minecraft Server



ExecStart=/bin/bash /opt/minecraft/start_server.sh

ExecStop=/usr/bin/screen -p 0 -S mc -X eval 'stuff "say SERVER SHUTTING DOWN IN 10 SECONDS..."\015'
ExecStop=/bin/sleep 10
ExecStop=/usr/bin/screen -p 0 -S mc -X eval 'stuff "save-all"\015'
ExecStop=/usr/bin/screen -p 0 -S mc -X eval 'stuff "stop"\015'


File /opt/minecraft/start_server.sh

/usr/bin/screen -DmS mc /usr/bin/java -Xms1024M -Xmx3G -jar spongeforge_server.jar nogui

Important commands for the service:

# activate the new service (only required once)
systemctl enable minecraft.service

# start, stop, status
systemctl start minecraft
systemctl stop minectraft
systemctl status minecraft

Debugging the server

Assuming that the Minecraft server was started as a systemd service a first way for debuggin is to have a look at the output of journalctl -u minecraft. More often than not, however, we will need direct access to the server console. Since the server was started in a detached screen window by the minecraft user we have to switch the user an re-attach to the panel:

# as root
su minecraft
script /dev/null/
screen -ls # list current screens
screen -r

Sending commands to the server

To make sending commands to the server a bit more convenient create a file named mc in /bin/:

echo "Sent the following command to your server '$cmd'"
screen -p 0 -S mc -X eval "\'stuff\' \"$cmd\"\015"

Since the screen was started by user minecraft you will need to switch to the user first (su minecraft) before being able to send commands to the detached screen (and by extension to the server). If it’s only a single command, as root it is also possible to use runuser -l minecraft mc say hello.

comments powered by Disqus