内卷地狱

Building a Minecraft Server on an Idle Raspberry Pi

Edit Me

A walkthrough of setting up a Raspberry Pi Minecraft server from scratch and exposing it to the internet using FRP port forwarding.

Hardware Prerequisites

One idle Raspberry Pi, and one VPS server with a public IP address.

Setting Up the Raspberry Pi

Flash the Raspberry Pi OS image, set up your username and password, then power it on.

Assign a Static IP to the Raspberry Pi

Open your router's settings panel and find the DHCP static IP allocation section. Assign a fixed IP to your Raspberry Pi. If you've forgotten the current IP, you can check it with:

$ hostname -I # Example output: 192.168.2.102

Enable VNC Remote Desktop

Log in via SSH and open the configuration panel:

$ sudo raspi-config
  1. Select Interface Options
  2. Select VNC
  3. When asked Would you like the VNC Server to be enabled?, select YES

Open a VNC client on your computer and log in with your username and password to access the virtual desktop.

Install Java

$ sudo -i # Temporarily gain admin privileges
$ cd /usr/local

Open the Raspberry Pi browser and download the JDK. The file will be in /home/<your-username>/Downloads/.

$ mkdir java
$ mv /home/<your-username>/Downloads/* /usr/local/java/
$ cd java
$ tar -zxvf jdk-21_linux-aarch64_bin.tar.gz
# Some log output will appear

Configure environment variables:

$ nano /etc/profile

Add the following at the end of the file:

# Adjust the JDK version number as needed
export JAVA_HOME=/usr/local/java/jdk-21.0.8
export CLASSPATH=.:$JAVA_HOME/lib/
export PATH=.:$JAVA_HOME/bin:$PATH
# To exit: Ctrl+O, Enter, Ctrl+X

Reload the file:

$ source /etc/profile

Verify the installation:

$ java -version

# Success looks like this:
java version "21.0.8" 2025-07-15 LTS
Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.8+12-LTS-250, mixed mode, sharing)

Download the Minecraft Server Jar

Open the browser and download the server jar. I'm using the Fabric server loader.

$ cd .. # Should return to /usr/local/
$ mkdir minecraft
$ mv /home/<your-username>/Downloads/* /usr/local/minecraft

The first run will fail because you haven't agreed to the EULA yet:

# My Pi has 8 GB RAM, so I'm allocating 4 GB here
# Note: the jar name will differ depending on the version you downloaded
$ java -Xmx4G -jar fabric-server-mc.1.21.1-loader.0.17.0-launcher.1.1.0.jar

Accept the EULA:

$ nano eula.txt # Change eula=false to eula=true
$ # To exit: Ctrl+O, Enter, Ctrl+X

Configure FRP

The Raspberry Pi uses the ARM architecture. Download frp — the latest version at the time of writing is 0.63.0.

$ cd .. # Should be in /usr/local/java
$ wget https://github.com/fatedier/frp/releases/download/v0.63.0/frp_0.63.0_linux_arm64.tar.gz
# Some log output will appear
$ tar -zxvf frp_0.63.0_linux_arm64.tar.gz
# Some log output will appear
$ mv frp_0.63.0_linux_arm64 frp # Rename for convenience

Edit the configuration:

$ cd frp
$ nano frpc.toml # 'c' in frpc stands for client

Edit frpc.toml:

serverAddr = "Your VPS public IP"
serverPort = 7000 # Default value
auth.method = "token"
auth.token = "set a password here"

[[proxies]]
name = "choose a service name"
type = "tcp"
localIP = "192.168.2.102" # Raspberry Pi IP
localPort = 25565 # MC server default port
remotePort = 25565 # MC server default port

## To exit: Ctrl+O, Enter, Ctrl+X

Install tmux

This guide uses tmux for session management. You could also use screen, but I prefer tmux.

$ apt install tmux

Setting Up the VPS

Log in via SSH using the root credentials from your provider's welcome email.

Configure FRP

Install frp on the VPS:

$ cd /usr/local
$ wget https://github.com/fatedier/frp/releases/download/v0.63.0/frp_0.63.0_linux_amd64.tar.gz
$ # Some log output will appear
$ tar -zxvf frp_0.63.0_linux_amd64.tar.gz
$ # Some log output will appear
$ mv frp_0.63.0_linux_amd64 frp # Rename for convenience

Edit the configuration:

$ cd frp
$ nano frps.toml # 's' in frps stands for server

Edit frps.toml:

bindPort = 7000
auth.method = "token"
auth.token = "same password as on the Raspberry Pi"

[webServer] # Optional dashboard — remove if not needed
addr = "127.0.0.1" # Not exposed publicly; access via SSH tunnel. Use "0.0.0.0" to expose publicly
port = 7500
user = "?"
password = "********"

Run FRP in the Background

Same process as on the Raspberry Pi:

$ apt install tmux

Open the required ports:

$ ufw allow 7000/tcp
$ ufw allow 25565/tcp

Start frp in a tmux session:

$ tmux new -s <service-name>
$ cd /usr/local/frp
$ ./frps -c frps.toml
# Press Ctrl+B then D to detach

Re-attach to the session later:

$ tmux attach -t <service-name>

Verify everything is running:

$ tmux ls
# frp: 1 windows (created <timestamp>)
$ ss -tlnp | grep 7000
# Output here means frp is working

Starting the Server on the Raspberry Pi

Write a Start Script

$ cd /usr/local/minecraft
$ nano start.sh

Set the contents of start.sh to:

#!/bin/bash
java -Xmx4G -jar fabric-server-mc.1.21.1-loader.0.17.0-launcher.1.1.0.jar nogui

Make it executable:

$ chmod +x start.sh

Run FRP and the Server

Run FRP

$ tmux new -s frp
$ cd /usr/local/frp
$ ./frpc -c frpc.toml
# Press Ctrl+B then D to detach

Run the Server

$ tmux new -s mcserver
$ cd /usr/local/minecraft
$ ./start.sh
# Press Ctrl+B then D to detach

Verify both are running:

$ tmux ls
# frp: 1 windows (created <timestamp>)
# mcserver: 1 windows (created <timestamp>)

(Optional) Configure a Domain Name

At this point you can already connect to the game using your VPS's public IP:

?.?.?.?:25565 # VPS public IP

If you have your own domain, log in to the Cloudflare dashboard and add a DNS record:

TypeA
Name (required)rasp
IPv4 address (required)<VPS public IP>
Proxy statusDNS only

Then you can connect using your domain:

rasp.<your-domain>:25565

贡献者


这篇文章有帮助吗?

最近更新

Involution Hell© 2026 byCommunityunderCC BY-NC-SA 4.0CCBYNCSA