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.
Minecraft requires Java to run. Here’s how to set it up:
Update the System:
- Run the following commands to update your server:
Install Java:
- Install OpenJDK, a free and open-source version of Java:
Verify Java Installation:
- Check if Java is installed correctly by running:
- This should output the installed Java version.
Create a Directory:
- Organize your server files by creating a dedicated folder:
Download the Server Jar:
- Download the latest Minecraft server jar using wget:
- Replace <server-jar-link> with the direct link for the latest server jar, found on the Minecraft server download page.
Run the Server for the First Time:
- Start the server to generate configuration files:
- The server will stop and prompt you to accept the EULA.
Accept the EULA:
- Open the EULA file and edit it:
- Change eula=false to eula=true. Save and exit using Ctrl + O, Enter, Ctrl + X.
Start the Server:
- Run the server again with the same command:
Monitor the Console:
- The server will initialize, and you can monitor logs and player activity in the console.
Allow Minecraft Traffic:
- Open port 25565, which is the default port for Minecraft:
Enable the Firewall:
- If the firewall is not already active, enable it:
To run the server in the background and ensure it restarts automatically:
Create a Service File:
- Open a new service file:
- Add the following content:
- Replace <your-username> with your Ubuntu username.
Enable and Start the Service:
- Reload systemd and start the service:
Get Your VPS IP:
- Retrieve your VPS’s public IP address using:
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!
Step 1: Update System and Install Java
Minecraft requires Java to run. Here’s how to set it up:
Update the System:
- Run the following commands to update your server:
sudo apt update && sudo apt upgrade -y
Install Java:
- Install OpenJDK, a free and open-source version of Java:
sudo apt install openjdk-17-jdk -y
Verify Java Installation:
- Check if Java is installed correctly by running:
java -version
- This should output the installed Java version.
Step 2: Create a Dedicated Directory for Minecraft
Create a Directory:
- Organize your server files by creating a dedicated folder:
mkdir -p ~/minecraft-server
cd ~/minecraft-server
Download the Server Jar:
- Download the latest Minecraft server jar using wget:
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.
Step 3: Configure the Server
Run the Server for the First Time:
- Start the server to generate configuration files:
java -Xmx1024M -Xms1024M -jar server.jar nogui
- The server will stop and prompt you to accept the EULA.
Accept the EULA:
- Open the EULA file and edit it:
nano eula.txt
- Change eula=false to eula=true. Save and exit using Ctrl + O, Enter, Ctrl + X.
Step 4: Run the Server
Start the Server:
- Run the server again with the same command:
java -Xmx1024M -Xms1024M -jar server.jar nogui
Monitor the Console:
- The server will initialize, and you can monitor logs and player activity in the console.
Step 5: Configure Firewall
Allow Minecraft Traffic:
- Open port 25565, which is the default port for Minecraft:
sudo ufw allow 25565
Enable the Firewall:
- If the firewall is not already active, enable it:
sudo ufw enable
Step 6: Set Up a Systemd Service (Optional)
To run the server in the background and ensure it restarts automatically:
Create a Service File:
- Open a new service file:
sudo nano /etc/systemd/system/minecraft.service
- Add the following content:
[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.
Enable and Start the Service:
- Reload systemd and start the service:
sudo systemctl daemon-reload
sudo systemctl start minecraft
sudo systemctl enable minecraft
Step 7: Connect to Your Server
Get Your VPS IP:
- Retrieve your VPS’s public IP address using:
curl ifconfig.me
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!
Updated on: 28/11/2024
Thank you!