I haven't figured out why yet it's not really safe - before I disabled some automatic updating of the server (or mcrcon?) it installed a crypto miner(!) and stored it in the ~minecraft/.ccache directory to try to hide it. The error is totally opaque unfortunately. Clearly it was looking for something there to start java. I had to disable the ProtectHome line to get it to start.
The following settings have to be changed in /var/minecraft/server/server.properties for this setup to work(keep replacing $port and $password with your own values): the systemd service uses this in its ExecStop part to gracefully shut down the server. You can connect to a running instance and execute commands using rcon. They enable the rcon protokoll of the minecraft server. The following 3 properties are important for the systemd rvice file to work properly. This is done in the file /var/minecraft/server/server.properties most of the setings do have good default values but everything can be changed as you like see: server.properties This file should be generated when you first run the server. Setting up the serverįirst of all you have to accept the eula to do so you have to add the line eula=true to /var/minecraft/server/eula.txt. So on CentOS you have to drop the ProtectHome, ProtectSystem and PrivateDevices otherwise you will probably get warnings in the log because those options were introduced in Systemd v214. Note on CentOSĪs CentOS has a quite old systemd Version there are some features missing.
Minecraft server jar file not opening how to#
The Install section specifies how to enable this service so that it is started every boot.Ĭreate the file in the directory /etc/systemd/system/rvice and paste the contents from above. you have to replace $port and $password with the actual values you specify in the server.properties file of the minecraft server. If you want to pass more advanced options to the server then this is most probably the place to do so.ĮxecStop specifies the command that is issued to stop the server. So if the server should be compromised in any way it should not be able to acess anything outside the /var/minecraft/server directory.ĮxecStart specifies the command that fires up the server. The following lines regulate the access of the server. The next line marks the service as sucessfully exited. Line 13 and 14 are more important again KillMode=none says that the server is not killed when the service is stoped but instead the ExecStop command is used to gracefully stop the server. I thought it might be usefull but actually I didn't use it. With line 12 I import a nf file that can be used to set various environment variables. I do that because my server hosts other services besides the minecraftserver that are more important to me. lines 9, 10 and 11 restrict the minecraft server so that it is run as minecraft user and group with a nice level of 5 meaning that it has a lower priority than most other things that run on the server. The Service section is the one that gets more interesting. Line 5 and 6 say that this service likes to have network available.
Minecraft server jar file not opening full#
Description = Minecraft Server Documentation = Wants = network.target After = network.target User = minecraft Group = minecraft Nice = 5 EnvironmentFile = -/var/minecraft/nf KillMode = none SuccessExitStatus = 0 1 ProtectHome = true ProtectSystem = full PrivateDevices = true NoNewPrivileges = true PrivateTmp = true InaccessibleDirectories = /root /sys /srv -/opt /media -/lost+found ReadWriteDirectories = /var/minecraft/server WorkingDirectory = /var/minecraft/server ExecStart = /usr/bin/java -Xmx1024M -Xms1024M -jar spigot.jar -noconsole ExecStop = /var/minecraft/mcrcon -H localhost -P $port -p $password stop WantedBy = multi-user.targetįirst the easy things: line 2 and 3 contain descriptive information you can fill in anything you like.