Run a Mincraft Server on your QNAP

After adding node.js to my QNAP I (or better: my kids) also wanted a Minecraft Server running on the device. Here I describe how to do this (based on the steps previously described here).

  1. Download the most recent JRE (32 Bit) from the Oracle Website and copy it into a shared folder of your QNAP
  2. unzip the file:
    #gunzip jre-8u45-linux-i586.gz.
    The result is a tar file (even Oracle forgot to add the .tar in the download)
  3. move the file to the lib directory (created when installing node.js):
    #mv jre-8u45-linux-i586 ../lib/
  4. Go to the lib folder and extract it:
    # tar xvf jre-8u45-linux-i586 and remove the tar file afterwards:
    # rm jre-8u45-linux-i586
    Test java by entering the directory ./jre1.8.0_45/bin and running the command ./java. The help text should appear.
  5. Go back to the lib folder and enter bin/, then create a link to java and javaw:
    # ln -s ../jre1.8.0_45/bin/java java
    # ln -s ../jre1.8.0_45/bin/javaws javaws

  6. Download the server jar file from https://minecraft.net/download and copy it to a shared folder on your QNAP.
  7. On the command line of the QNAP move this jar file to the lib folder and enter its directory
    # mkdir ../lib/minecraft_server
    # mv minecraft_server.1.8.6.jar ../lib/minecraft_server/
    # cd ../lib/minecraft_server/
  8. Start the server the first time
    java -Xms1G -Xmx1G -jar minecraft_server.1.8.6.jar nogui
    This will issue an error message as the EULA wasn’t agreed so far. Edit eula.txt according to the instructions found there and start again. This time the server should start, creating a new world and the settings file.

  9. To run minecraft server in PM2, create a shell script (minecraft_server.sh) in the same folder as processes.json with the following content:
    #!/bin/sh
    cd /share/CACHEDEV1_DATA/lib/minecraft_server/
    java -Xms1G -Xmx1G -jar minecraft_server.1.8.6.jar nogui

    don’t forget to make it executable.
  10. Add this shell script to processes.json
    {
    "name": "minecraft_server",
    "script": "/share/CACHEDEV1_DATA/node/minecraft_server.sh",
    "exec_mode": "fork_mode",
    "exec_interpreter": "bash"
    }
  11. Start PM2 and the minecraft server should be started as well
    pm2 start processes.json

Leave a Reply