目錄
✅ 2. Install Java
✅ 3. Create a User for the Server (Optional but Recommended)
✅ 4. Download Minecraft Server JAR
✅ 5. Run the Server Once to Generate Config Files
✅ 6. Start the Server Again
✅ 7. Make It Run in Background (Use Screen or Systemd)
Option A: Using screen (Simple)
Option B: Use a systemd service (Better for auto-start)
✅ 8. Open the Port
✅ Bonus Tips
首頁 系統教程 Linux 在Linux VPS上設置Minecraft服務器

在Linux VPS上設置Minecraft服務器

Aug 01, 2025 am 04:37 AM

  1. 更新系統:運行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

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).

Setting up a Minecraft Server on a Linux VPS

✅ 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 ):

Setting up a Minecraft Server on a Linux VPS
 sudo apt install openjdk-17-jdk -y

Check it's installed:

 java -version

You should see something like openjdk version "17.xx" .

Setting up a Minecraft Server on a Linux VPS

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 (especially world/ ).
  • 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中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

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

熱門文章

Rimworld Odyssey溫度指南和Gravtech
1 個月前 By Jack chen
Rimworld Odyssey如何釣魚
1 個月前 By Jack chen
我可以有兩個支付帳戶嗎?
1 個月前 By 下次还敢
初學者的Rimworld指南:奧德賽
1 個月前 By Jack chen
PHP變量範圍解釋了
3 週前 By 百草

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

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

熱門話題

Laravel 教程
1603
29
PHP教程
1506
276
如何在Rocky Linux 8上安裝Nodejs 14/16&npm 如何在Rocky Linux 8上安裝Nodejs 14/16&npm Jul 13, 2025 am 09:09 AM

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

安裝Linux的系統要求 安裝Linux的系統要求 Jul 20, 2025 am 03:49 AM

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

如何在桌面Linux上安裝和使用ProtonVPN 如何在桌面Linux上安裝和使用ProtonVPN Jul 13, 2025 am 09:12 AM

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

如何從CentOS遷移到Oracle Linux 如何從CentOS遷移到Oracle Linux Jul 14, 2025 am 09:19 AM

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

如何在Linux上安全刪除硬盤驅動器 如何在Linux上安全刪除硬盤驅動器 Jul 24, 2025 am 12:08 AM

確認目標硬盤設備名(如/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 15:為每個人製作精美的Linux發行 Deepin 15:為每個人製作精美的Linux發行 Jul 14, 2025 am 09:10 AM

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

如何使用&#039; speedtest-cli&#039;工具 如何使用&#039; speedtest-cli&#039;工具 Jul 14, 2025 am 09:12 AM

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

如何使用端口敲門來確保Linux中的SSH服務 如何使用端口敲門來確保Linux中的SSH服務 Jul 14, 2025 am 09:20 AM

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

See all articles