Linux Minecraft Server

 

Minecraft Server Setup on Linux – CentOS 7

1. Download Java JRE rpm from Oracle.
jre-8u66-linux-x64.rpm

2. Install Java
# yum install jre-8u66-linux-x64.rpm

3. Verify Java installation:

$ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

4. Download the Minecraft Server from:
https://minecraft.net
minecraft_server.1.8.8.jar

5. Create a directory for the Minecraft server files.

6. Launch the minecraft_server.1.8.8.jar
$ java -d64 -Xms10G -Xmx20G -jar minecraft_server.1.8.8.jar nogui
-Xms is the min memory and -Xmx is the max memory allocated to java in Gigabytes.

Note: It will initially fail because of eula.txt

$ java -d64 -Xms10G -Xmx20G -jar minecraft_server.1.8.8.jar nogui
.....
[21:22:12] [Server thread/WARN]: Failed to load eula.txt
[21:22:12] [Server thread/INFO]: You need to agree to the EULA in order to run the server...
[21:22:12] [Server thread/INFO]: Stopping server
[21:22:12] [Server Shutdown Thread/INFO]: Stopping server

7. During the initial launch of the Minecraft Server, it will add the eula.txt file in the directory.
Edit the eula.txt file, change the eula=false to eula=true

8. Re start the Minecraft Server

$ java -d64 -Xms10G -Xmx20G -jar minecraft_server.1.8.8.jar nogui
[21:35:53] [Server thread/INFO]: Starting minecraft server version 1.8.8
[21:35:53] [Server thread/INFO]: Loading properties
[21:35:53] [Server thread/INFO]: Default game type: SURVIVAL
[21:35:53] [Server thread/INFO]: Generating keypair
.
.
.
[21:35:58] [Server thread/INFO]: Preparing spawn area: 31%
[21:35:59] [Server thread/INFO]: Done...

Type /stop to stop the Minecraft Server

9. Setup the server.properties
Example of server.properties

$ cat server.properties
#Minecraft server properties
#Fri Oct 30 17:56:45 PDT 2015
spawn-protection=0
max-tick-time=60000
server-name=MyServer.com
generator-settings=
force-gamemode=true
allow-nether=true
gamemode=0
enable-query=false
player-idle-timeout=60
difficulty=3
spawn-monsters=true
op-permission-level=4
resource-pack-hash=
announce-player-achievements=true
pvp=true
snooper-enabled=false
level-type=DEFAULT
hardcore=false
enable-command-block=true
max-players=25
network-compression-threshold=256
max-world-size=29999984
server-port=25565
server-ip=xxx.xxx.xxx.xxx
spawn-npcs=true
allow-flight=false
level-name=TheWalkingDead
view-distance=12
resource-pack=
spawn-animals=true
white-list=false
generate-structures=true
online-mode=true
max-build-height=256
level-seed=8678942899319966093
use-native-transport=true
motd=Hello
enable-rcon=false

10. Add the initial player and admin to
ops.json and whitelist.json

Example of ops.json format:

[
  {
    "uuid": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "name": "Ferdz",
    "level": 4
  }
]

Example of whitelist.json

[
  {
    "uuid": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "name": "Ferdz",
  }
]

The rest of the players can be added in the minecraft console.

11. Use screen to lanch the minecraft server.
Screen session, -S sets the sessions title:
$ screen -S “Minecraft Server”

Launch the Minecraft Server:
$ java -d64 -Xms10G -Xmx20G -jar minecraft_server.1.8.8.jar nogui

To Dettach Screen:
ctl-a d

To reattach to the Minecraft Server session
$ screen -R
-R attempts to resume the first detached screen session it finds.

To list screen session
$ screen -list