Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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. ====== 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: [[https://www.freshports.org/games/minecraft-server/|games/minecraft-server]]. Pre-compiled (binary) packages are not available to due the software license prohibiting distribution. ====== Preparation steps ====== Update the %%FreeBSD%% [[Glossary#Base|base]] system if needed. Run [[https://man.freebsd.org/freebsd-update(8)|freebsd-update]] <code> # freebsd-update fetch install </code> Reboot if necessary. <code> # shutdown -r now </code> ====== 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: <code> 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 </code> ====== 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|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: * [[#plain-ports|Plain Ports Method]] * [[#poudriere|Poudriere Method]] ====== Method #1: Plain Ports ====== You can use [[https://man.freebsd.org/portsnap(8)|portsnap]] or ''%%git%%'' Run portsnap, which installs the [[Ports]] tree in ''%%/usr/ports/%%'' <code> # portsnap fetch extract </code> # git thing here ===== Accept the Minecraft License ===== Set acceptance of the Minecraft LICENSE. To do that we'll create a ''%%/etc/make.conf%%'' <code> # echo "LICENSES_ACCEPTED+= minecraft" >> /etc/make.conf </code> ===== 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|portmaster]] ports tool ([[https://www.freshports.org/ports-mgmt/portmaster|ports-mgmt/portmaster]]). Plain ports: <code> # cd /usr/ports/games/minecraft-server && make install clean </code> or using portmaster: <code> # portmaster games/minecraft-server </code> Additional Reading: * [[https://man.freebsd.org/portmaster(8)|portmaster manual page]] * [[https://man.freebsd.org/ports(7)|ports manual page]] ====== Method #2: Poudriere ====== Accept the Minecraft license Poudriere's default make.conf location is different (''%%LOCALBASE/etc/poudriere.d/make.conf%%'') .. <code> # echo "LICENSES_ACCEPTED+= minecraft" >> /usr/local/etc/poudriere.d/make.conf </code> Create a poudriere ports tree: ([[https://man.freebsd.org/poudriere-ports|poudriere-ports(8) manual page]]) <code> # poudriere ports -c -m git+ssh </code> Build the Minecraft server port (create a package) Poudriere: <code> # echo "games/minecraft-server" > portlist # poudriere bulk -j JAIL_NAME -f portlist </code> See: [[https://man.freebsd.org/poudriere(8)|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) Further reading: * [[https://github.com/freebsd/poudriere/wiki|Poudriere Wiki]] * [[https://wiki.freebsd.org/VladimirKrstulja/Guides/Poudriere|Poudriere Guide]] ====== Run the server ====== 4. After all ports have been built we can run the **Minecraft** server with the following command: <code> # cd /usr/local/minecraft-server; /usr/local/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui </code> The output will be: <code> ... [ServerMain/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info. </code> To fix this we need to accept the license. This can be done by editing **/usr/local/etc/minecraft-server/eula.txt**: <code> eula=false </code> 5. From now on the server can be started on the shell with the given command. <code> # cd /usr/local/minecraft-server; /usr/local/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui </code> **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: <code> [15:07:31] [Server thread/INFO]: user joined the game </code> 7. Have fun and enjoy playing :) ===== Credits ===== * Article originally written by jhx((https://twitter.com/someonenamedjhx/status/1586254456249028609)) ---- {{tag>Gaming}} {{tag>HowTo}} minecraftserver.txt Last modified: 2022/10/29 11:24by KubilayKocak