Minecraft is a popular sandbox video game that allows players to build and explore their own virtual worlds. While the game can be played in single-player mode, many players prefer to play on multiplayer servers with friends or other players from around the world. In this guide, we’ll show you how to set up your own Minecraft server on a Linux VPS (Virtual Private Server).
Step 1: Choose a VPS Provider
The first step in setting up your Minecraft server is to choose a VPS provider. There are many providers to choose from, including DigitalOcean, Linode, Vultr, and more. Each provider offers different plans with different specifications, so it’s important to choose one that meets your needs.
For this guide, we’ll be using a DigitalOcean VPS with Ubuntu 20.04 as the operating system.
Step 2: Connect to Your VPS
Once you’ve chosen a VPS provider and created your account, you’ll need to connect to your VPS. This can be done using an SSH client like PuTTY or the built-in terminal on your computer.
To connect to your VPS, you’ll need the IP address and login credentials provided by your VPS provider. Once you’re connected, you should see a command prompt.
Step 3: Install Java
Minecraft servers require Java to run, so the next step is to install Java on your VPS. You can install Java using the following command:
sudo apt update
sudo apt install openjdk-8-jdk
This command will update the package list and install the OpenJDK 8 package, which is compatible with Minecraft.
Step 4: Create a New User
It’s recommended to run your Minecraft server as a separate user to improve security. You can create a new user using the following command:
sudo adduser minecraft
This command will create a new user called “minecraft”. You’ll be prompted to set a password and provide some other information.
Step 5: Download and Install Minecraft Server
The next step is to download and install the Minecraft server software. You can download the latest version from the official Minecraft website:
sudo wget -O minecraft_server.jar https://launcher.mojang.com/v1/objects/367cd54a269bd9f78d34cf951dcaed35045080a0/server.jar
This command will download the Minecraft server JAR file to your VPS. You can verify the file’s integrity by checking the SHA-1 hash:
echo "367cd54a269bd9f78d34cf951dcaed35045080a0 minecraft_server.jar" | sha1sum -c -
This command should output “minecraft_server.jar: OK”.
Next, create a new directory for your Minecraft server:
Move the downloaded Minecraft server JAR file to this directory:
mv ../minecraft_server.jar .
Finally, start the Minecraft server with the following command:
sudo java -Xms512M -Xmx1024M -jar minecraft_server.jar nogui
This command starts the Minecraft server with 512 MB of minimum memory and 1024 MB of maximum memory.
Step 6: Configure Minecraft Server Settings
Before you start your Minecraft server, you’ll need to configure some server settings. This includes setting the server name, game mode, and difficulty level.
Open the server.properties file in a text editor:
You can edit the following settings:
- ‘server-name’: Set this to the name of your server.
- ‘gamemode’: Set this to either “survival”, “creative”, or “adventure”.
- ‘difficulty’: Set this to the desired difficulty level, such as “easy”, “normal”, or “hard”.
- ‘max-players’: Set this to the maximum number of players allowed on the server.
Save your changes and exit the text editor.
Step 7: Configure Firewall
By default, Linux servers come with a firewall called “iptables” that restricts incoming connections. You’ll need to configure the firewall to allow incoming connections on the Minecraft server port (25565) so that players can connect to your server.
You can configure the firewall using the following commands:
sudo iptables -A INPUT -p tcp --dport 25565 -j ACCEPT
sudo iptables-save > /etc/iptables.rules
The first command adds a new rule to the firewall to allow incoming connections on port 25565. The second command saves the firewall rules so that they’re applied after a reboot.
Step 8: Start Minecraft Server on Boot
If you want your Minecraft server to start automatically whenever your VPS reboots, you can create a systemd service file.
Create a new file called minecraft.service in the /etc/systemd/system/ directory:
sudo nano /etc/systemd/system/minecraft.service
Paste the following configuration into the file:
[Unit] Description=Minecraft Server After=network.target [Service] User=minecraft Nice=1 KillMode=none SuccessExitStatus=0 1 ProtectHome=true ProtectSystem=full PrivateDevices=true NoNewPrivileges=true WorkingDirectory=/home/minecraft/minecraft_server ExecStart=/usr/bin/java -Xms512M -Xmx1024M -jar minecraft_server.jar nogui ExecStop=/bin/sh -c 'screen -S minecraft -X stuff "stop$(printf \\r)"' [Install] WantedBy=multi-user.target
This configuration sets up the Minecraft server to run as the “minecraft” user, sets some security options, and specifies the command to start the Minecraft server.
Save your changes and exit the text editor.
Finally, start the Minecraft service and enable it to start on boot:
sudo systemctl start minecraft
sudo systemctl enable minecraft
Step 9: Connect to Your Minecraft Server
Now that your Minecraft server is up and running, you can connect to it from the Minecraft game client.
Open Minecraft on your computer and click “Multiplayer”. Click “Add Server” and enter the IP address of your VPS in the “Server Name” field. Enter “25565” as the server port and click “Done”.
Click on the server in the server list and click “Join Server”. You should now be connected to your own Minecraft server.
Congratulations, you’ve successfully set up your own Minecraft server on a Linux VPS! With your new server, you can invite friends to play together and explore your own unique virtual world. By following these steps, you can customize your Minecraft experience and create a safe and enjoyable environment for players.
Leave a Reply
You must be logged in to post a comment.