在Linux VPS上設置Minecraft服務器
- 更新系統:運行sudo apt update && sudo apt upgrade -y確保環境最新;2. 安裝Java:用sudo apt install openjdk-17-jdk -y安裝適配新版Minecraft的OpenJDK 17;3. 創建專用用戶:執行adduser minecraft並切換su - minecraft提升安全性;4. 下載服務端JAR:使用wget獲取官方Minecraft服務器jar文件並重命名為minecraft_server.jar;5. 首次運行生成配置:執行java -Xmx2G -Xms1G -jar minecraft_server.jar nogui後修改eula.txt中eula=true;6. 再次啟動服務:同樣命令再次運行服務器並正常關閉以完成初始化;7. 後台運行設置:可選screen或創建systemd服務(推薦)實現開機自啟;8. 開放端口:通過sudo ufw allow 25565/tcp並確認VPS防火牆放行該端口;9. 連接測試:在Minecraft客戶端添加服務器IP:25565驗證成功連接,至此你已擁有一個穩定運行於Linux VPS上的Minecraft服務器。
Setting up a Minecraft server on a Linux VPS isn't as intimidating as it sounds—especially if you're comfortable with basic command-line tools. Here's how to do it step by step, assuming you're using Ubuntu or Debian (most common for VPS providers like DigitalOcean, Linode, or AWS).

✅ 1. Update Your System
Before installing anything, make sure your system is up to date:
sudo apt update && sudo apt upgrade -y
✅ 2. Install Java
Minecraft Java Edition servers require Java. Install OpenJDK 17 (recommended for newer Minecraft versions like 1.17 ):

sudo apt install openjdk-17-jdk -y
Check it's installed:
java -version
You should see something like openjdk version "17.xx"
.

✅ 3. Create a User for the Server (Optional but Recommended)
Don't run Minecraft as root. Create a dedicated user:
adduser minecraft
Then switch to that user:
su - minecraft
✅ 4. Download Minecraft Server JAR
Go to the official Minecraft server download page and copy the latest server JAR link.
In your terminal (as the minecraft
user):
wget <paste-the-jar-url-here> # Example: wget https://piston-data.mojang.com/v1/objects/84194a2f286ef7c1cfed88c85b5238f8075e168e/server.jar
Rename it for simplicity (optional):
mv server.jar minecraft_server.jar
✅ 5. Run the Server Once to Generate Config Files
java -Xmx2G -Xms1G -jar minecraft_server.jar nogui
-
-Xmx2G
= max RAM (adjust based on your VPS—1GB min, 2–4GB ideal) -
-Xms1G
= starting RAM -
nogui
= no GUI (required on headless servers)
This will fail the first time because eula.txt
doesn't exist yet.
Now edit the EULA:
nano eula.txt
Change eula=false
to eula=true
, save and exit ( Ctrl O
, Enter
, Ctrl X
).
✅ 6. Start the Server Again
java -Xmx2G -Xms1G -jar minecraft_server.jar nogui
Now it should start and generate world files, server.properties
, etc.
Once it fully starts, type stop
in the console to shut it down cleanly.
✅ 7. Make It Run in Background (Use Screen or Systemd)
Option A: Using screen
(Simple)
Install screen:
sudo apt install screen -y
Then:
screen -S minecraft java -Xmx2G -Xms1G -jar minecraft_server.jar nogui
Press Ctrl A
, then D
to detach. To reattach later:
screen -r minecraft
Option B: Use a systemd service (Better for auto-start)
As root, create a service file:
sudo nano /etc/systemd/system/minecraft.service
Paste this (adjust paths and RAM):
[Unit] Description=Minecraft Server After=network.target [Service] User=minecraft WorkingDirectory=/home/minecraft ExecStart=/usr/bin/java -Xmx2G -Xms1G -jar minecraft_server.jar nogui Restart=always [Install] WantedBy=multi-user.target
Save, then:
sudo systemctl enable minecraft.service sudo systemctl start minecraft.service
Check status:
sudo systemctl status minecraft.service
✅ 8. Open the Port
Minecraft uses port 25565 by default. Allow it:
sudo ufw allow 25565/tcp
(If UFW isn't set up yet, run sudo ufw enable
first.)
Also make sure your VPS provider allows that port in their firewall/network settings (eg, DigitalOcean Cloud Firewalls).
✅ 9. Connect to Your Server
From the Minecraft client:
- Multiplayer → Add Server
- Server Address:
your.vps.ip.address:25565
If you can connect, congrats! You've got a working server.
✅ Bonus Tips
- Backups : Regularly back up the
/home/minecraft
folder (especiallyworld/
). - Plugins : Install PaperMC instead of vanilla for better performance and plugin support.
- Performance : If your VPS has 1GB RAM or less, consider using Aikar's flags for better GC tuning.
That's it! You now have a functional, background-running Minecraft server on your Linux VPS.
No need for hosting services—just your own box and a little command line magic.
以上是在Linux VPS上設置Minecraft服務器的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undress AI Tool
免費脫衣圖片

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Node.js建立在Chrome的V8引擎上,是一種開源的,由事件驅動的JavaScript運行時環境,用於構建可擴展應用程序和後端API。 Nodejs因其非阻滯I/O模型而聞名輕巧有效,並且

LinuxCanrunonModestHardwarewtareWithSpecificminimumRequirentess.A1GHZPROCESER(X86ORX86_64)iSNEDED,withAdual-Corecpurecommondend.r AmshouldBeatLeast512MbForCommand-lineUseor2Gbfordesktopenvironments.diskSpacePacereQuiresaminimumof5-10GB,不過25GBISBISBETTERFORAD

VPN(虛擬專用網絡)是一條通過公共網絡擴展的加密隧道。它允許用戶以最大的隱私和機密性安全地瀏覽和訪問Internet連接的資源。 [您可能也喜歡:13個最佳VPN

隨著從CentOS項目轉變為Centos流(現在將作為RHEL上游的Centos流)轉變,已經提出了幾種CentOS替代方案來替換Centos 8.長期以來,CentOS已被小型企業廣泛採用

確認目標硬盤設備名(如/dev/sda),避免誤刪系統盤;2.使用sudoddif=/dev/zeroof=/dev/sdXbs=1Mstatus=progress全盤覆寫零值,適用於大多數場景;3.敏感數據使用sudoshred-v-n3/dev/sdX進行三次隨機數據覆寫,確保無法恢復;4.可選執行sudobadblocks-wsv/dev/sdX做破壞性寫入測試;最後用sudohexdump-C/dev/sdX|head驗證是否全為零,完成安全擦除。

Deepin OS代表Linux分佈中的顯著演變。讓我澄清一下 - 我可能對“革命性”略微誇大了,但老實說,自從我遇到了一個真正給我留下深刻印象的Linux發行版以來,已經有一段時間了。

我們始終需要檢查在家和辦公室的互聯網連接速度。我們該怎麼辦?轉到SpeedTest.net等網站並開始測試。它在Web瀏覽器中加載JavaScript,然後根據ping選擇最佳服務器

端口敲門是一種僅允許合法用戶訪問服務器上運行的服務來控制端口訪問的漂亮技術。它以這樣的方式工作,當進行正確的連接嘗試序列時,防火牆很樂意操作
