> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.vibegames.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to Create a Minecraft Server on an Linux VPS

This guide will walk you through setting up a Minecraft server on an Linux VPS. We are using Ubuntu because of its stability, simplicity, and wide community support, making it an excellent choice for hosting servers.

---

## Step 1: Update System and Install Java
Minecraft requires Java to run. Here’s how to set it up:

1. **Update the System:**
   - Run the following commands to update your server:
     ```bash
     sudo apt update && sudo apt upgrade -y
     ```
2. **Install Java:**
   - Install OpenJDK, a free and open-source version of Java:
     ```bash
     sudo apt install openjdk-17-jdk -y
     ```
3. **Verify Java Installation:**
   - Check if Java is installed correctly by running:
     ```bash
     java -version
     ```
   - This should output the installed Java version.

---

## Step 2: Create a Dedicated Directory for Minecraft
1. **Create a Directory:**
   - Organize your server files by creating a dedicated folder:
     ```bash
     mkdir -p ~/minecraft-server
     cd ~/minecraft-server
     ```
2. **Download the Server Jar:**
   - Download the latest Minecraft server jar using `wget`:
     ```bash
     wget https://launcher.mojang.com/v1/objects/<server-jar-link>/server.jar
     ```
   - Replace `<server-jar-link>` with the direct link for the latest server jar, found on the [Minecraft server download page](https://www.minecraft.net/en-us/download/server).

---

## Step 3: Configure the Server
1. **Run the Server for the First Time:**
   - Start the server to generate configuration files:
     ```bash
     java -Xmx1024M -Xms1024M -jar server.jar nogui
     ```
   - The server will stop and prompt you to accept the EULA.
2. **Accept the EULA:**
   - Open the EULA file and edit it:
     ```bash
     nano eula.txt
     ```
   - Change `eula=false` to `eula=true`. Save and exit using `Ctrl + O`, `Enter`, `Ctrl + X`.

---

## Step 4: Run the Server
1. **Start the Server:**
   - Run the server again with the same command:
     ```bash
     java -Xmx1024M -Xms1024M -jar server.jar nogui
     ```
2. **Monitor the Console:**
   - The server will initialize, and you can monitor logs and player activity in the console.

---

## Step 5: Configure Firewall
1. **Allow Minecraft Traffic:**
   - Open port `25565`, which is the default port for Minecraft:
     ```bash
     sudo ufw allow 25565
     ```
2. **Enable the Firewall:**
   - If the firewall is not already active, enable it:
     ```bash
     sudo ufw enable
     ```

---

## Step 6: Set Up a Systemd Service (Optional)
To run the server in the background and ensure it restarts automatically:

1. **Create a Service File:**
   - Open a new service file:
     ```bash
     sudo nano /etc/systemd/system/minecraft.service
     ```
   - Add the following content:
     ```ini
     [Unit]
     Description=Minecraft Server
     After=network.target

     [Service]
     User=<your-username>
     WorkingDirectory=/home/<your-username>/minecraft-server
     ExecStart=/usr/bin/java -Xmx1024M -Xms1024M -jar server.jar nogui
     Restart=always

     [Install]
     WantedBy=multi-user.target
     ```
     - Replace `<your-username>` with your Ubuntu username.

2. **Enable and Start the Service:**
   - Reload systemd and start the service:
     ```bash
     sudo systemctl daemon-reload
     sudo systemctl start minecraft
     sudo systemctl enable minecraft
     ```

---

## Step 7: Connect to Your Server
1. **Get Your VPS IP:**
   - Retrieve your VPS’s public IP address using:
     ```bash
     curl ifconfig.me
     ```
2. **Launch Minecraft:**
   - Open Minecraft, go to multiplayer, and add a server using your VPS IP.

Your Minecraft server is now live and ready for players!