FreeBSD Minecraft Server

This article describes how to setup and run a Minecraft server on FreeBSD. It assumes only an existing FreeBSD installation with SSH or Physical access.

Contents

  1. FreeBSD Minecraft Server
  2. Requirements
  3. Preparation steps
  4. Minecraft Server Options
  5. Installation Methods
  6. Method #1: Plain Ports
  7. Method #2: Poudriere
  8. Run the server

Requirements

These instructions were tested on FreeBSD 13.1-RELEASE amd64 with 2 Virtual CPU's, 2Gb memory, though it should be possible to run a Minecraft server on any platform that supports Java, either natively or via poudriere/qemu. This can enable running a Minecraft server on popular devices such as Raspberry Pi's, which are supported by FreeBSD.

Minecraft can be pretty resource hungry! Make sure to provide at least a couple of GB's of RAM and a not too low end CPU.

In the commands below, # means as the root user, $ means as a normal (unprivileged) user. You can use su or sudo or your preferred method to execute root commands.

The Minecraft dedicated server software is available from the FreeBSD Ports tree: games/minecraft-server. Pre-compiled (binary) packages are not available to due the software license prohibiting distribution.

Preparation steps

Update the FreeBSD base system if needed.

Run freebsd-update

  • # freebsd-update fetch install

Reboot if necessary.

  • # shutdown -r now

Minecraft Server Options

The port itself gives two options: STANDALONE or DAEMON

DAEMON pulls in tmux - which is terminal multiplexer. You can run the Java .jar inside tmux and detach from the current session - this will result in the server continuing to run since the terminal session is not closed.

Selecting DAEMON also creates a RC script for you. This can be very handy if you don't want to start the server on the shell every time. Another possibility would also to be using tmux.

STANDALONE installs the .jar Java file which can be run by hand on the terminal. It is also possible to write a simple RC script which would handle starting and stopping the server.

NOTE: I have chosen STANDALONE in this guide.

The following will be provided:

  • With daemon option:
    - The service has been installed with the name 'minecraft'
    - To adjust maximum memory usage (-Xmx), use minecraft_memx= in /etc/rc.conf
    - To adjust initial memory usage (-Xms), use minecraft_mems= in /etc/rc.conf
    - To add other java parameters, use minecraft_args= in /etc/rc.conf
    - To see the interactive console, type service minecraft console

Installation Methods

We provide two main methods below to building the Minecraft server software.

The Plain Ports method requires only obtaining the Ports tree, and is suitable for single instance, local installation, or experimentation without additional tooling setup and configuration.

The Poudriere method is great for anyone who:

  • Would like to build once and install many times or continuous builds
  • Would like to run multiple server installations
  • Would like to contribute to updates or improvements to Minecraft server or ecosystem FreeBSD ports
  • Has an existing Poudriere or custom package repository setup.

Choose:

Method #1: Plain Ports

You can use portsnap or git

Run portsnap, which installs the Ports tree in /usr/ports/

  • # portsnap fetch extract

# git clone https://git.freebsd.org/ports.git /usr/ports/

Accept the Minecraft License

Set acceptance of the Minecraft LICENSE. To do that we'll create a /etc/make.conf

  • # echo "LICENSES_ACCEPTED+= minecraft" >> /etc/make.conf

Build the Minecraft Server Port

Building the minecraft server port can be done with in a couple of ways, make install command from the ports framework or using the portmaster ports tool (ports-mgmt/portmaster).

Plain ports:

  • # cd /usr/ports/games/minecraft-server && make install clean

or using portmaster:

  • # portmaster games/minecraft-server

Additional Reading:

Method #2: Poudriere

Accept the Minecraft license

Poudriere's default make.conf location is different (LOCALBASE/etc/poudriere.d/make.conf) ..

  • # echo "LICENSES_ACCEPTED+= minecraft" >> /usr/local/etc/poudriere.d/make.conf

Create a poudriere ports tree:

(poudriere-ports(8) manual page)

  • # poudriere ports -c -m git+ssh

Build the Minecraft server port (create a package)

Poudriere:

  • # echo "games/minecraft-server" > portlist
    # poudriere bulk -j JAIL_NAME -f portlist

See: poudriere(8) manual page

(To configure the port interactively one most run poudriere options command.

Keep that in mind if you want to make any alterations)

Run the server

4. After all ports have been built we can run the Minecraft server with the following command:

  • # cd /usr/local/minecraft-server; /usr/local/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui

The output will be:

  • ...
    [ServerMain/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

To fix this we need to accept the license. This can be done by editing /usr/local/etc/minecraft-server/eula.txt:

  • eula=false

5. From now on the server can be started on the shell with the given command.

  • # cd /usr/local/minecraft-server; /usr/local/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui

On the first run there will be quite some CPU load to generate the world - keep that in mind!

This will run the server with 1GB of memory allocated. Depending on the size of your instance the amount of memory may need to be adjusted.

6. The output of the server also shows a successful connection to the instance:

  • [15:07:31] [Server thread/INFO]: user joined the game

7. Have fun and enjoy playing :)

Credits

  • Article originally written by jhx1


CategoryGaming CategoryHowTo

  1. https://twitter.com/someonenamedjhx/status/1586254456249028609 (1)

MinecraftServer (last edited 2025年04月06日T08:09:13+0000 by bunny )

AltStyle によって変換されたページ (->オリジナル) /