Introduction: This tutorial is designed to walk you through the process of setting up a Minecraft server on your VPS or dedicated server. Please note that this tutorial is tested on Ubuntu 22.04 LTS.

Prerequisites:

  1. A local device for connecting to the game.
  2. A server running Ubuntu to host the Minecraft game.
  3. Access to the root user or a user with sudo permissions.

Before you can start playing on the server, there are some essential configurations to be made, including setting up a firewall. For detailed instructions, refer to the "Initial Server Setup with Ubuntu" guide.

Example Terminology:

In this tutorial, we'll use the following example values:

  • <Your_Public_IP> - Replace this with the actual public IP address of your remote server.
  • <Your_Minecraft_Username> - Replace this with your preferred username for the Minecraft server.

Step 1 - Creating a User: It's not advisable to use the root user for running Minecraft since it has unrestricted access to execute any command, which can lead to unintended changes. To prevent this, it's better to create a new user with sudo privileges.

Run the following command to create a new user for your Minecraft server:

adduser <Your_Minecraft_Username>

You'll be prompted to set a secure password for this user. Fill in the required information as needed.

Next, add the new user to the sudo group:

usermod -aG sudo <Your_Minecraft_Username>

Now, switch to the newly created user:

su <Your_Minecraft_Username> cd ~

Step 2 - Preparing the Server: Minecraft servers typically run on port 25565, and Java is required to run Minecraft. Here's what you need to do:

Step 2.1 - Opening Port 25565: If your server has a firewall, ensure that it allows traffic on port 25565 for both TCP and UDP. This will enable your local device to connect to the Minecraft game on your server. This tutorial covers two firewall tools: UFW (default for Ubuntu) and Hetzner Cloud Firewall. Adjust the steps based on your firewall setup if different.

Step 2.2 - Installing Java: Java is essential for running Minecraft. First, check if Java is already installed:

java --version

If Java is not installed, you can install it with:

sudo apt update && sudo apt install openjdk-19-jdk-headless openjdk-19-jre-headless -y

To confirm the installation, use the java --version command again.

Step 3 - Installing Minecraft: With port 25565 open and Java installed, you can proceed to install Minecraft itself. You can find the server release of Minecraft on minecraft.net or papermc.io. Follow these steps:

  1. Create a new directory for the Minecraft files and navigate to it:
mkdir MinecraftServer && cd MinecraftServer
  1. Visit minecraft.net or papermc.io, choose a version, and copy the link to the JAR file. Use either of the following commands (not both) to download the server JAR file:

minecraft.net:

wget https://piston-data.mojang.com/v1/objects/84194a2f286ef7c14ed7ce0090dba59902951553/server.jar

papermc.io:

wget -O server.jar https://api.papermc.io/v2/projects/paper/versions/1.20.1/builds/129/downloads/paper-1.20.1-129.jar

If you wish to install a different version, replace the link in the command with your desired version.

  1. Confirm that the JAR file is downloaded to your server using ls -al. You should have only one JAR file in your directory; you can delete any additional ones.

  2. Accept the End User License Agreement (EULA) by editing the eula.txt file:

nano eula.txt

Change eula=false to eula=true, save the file by pressing Ctrl+X, followed by Y, and then Enter.

Step 4 - Starting the Server: Now that everything is prepared, you can start the Minecraft server. To keep it running even when your terminal session ends, we'll use the screen tool:

Installing screen (if not already installed):

sudo apt install screen -y

Starting the Minecraft server in a screen session:

screen -S MinecraftServer

Replace "MinecraftServer" with your preferred session name.

Navigate to the Minecraft directory:

cd ~/MinecraftServer

Start the Minecraft server with the desired amount of RAM (replace <MEMORY> with the maximum RAM you want to allocate in MB):

java -Xms512M -Xmx<MEMORY>M -jar server.jar
  • -Xms: Minimum RAM allocated to the Minecraft server (e.g., 512M).
  • -Xmx: Maximum RAM allocated to the Minecraft server (e.g., <MEMORY>M).

You should now be in the Minecraft console, where you can enter Minecraft commands.

Test the server by using /list:

/list

This command should display the number of players online.

Step 5 - Managing the screen Session: To exit the screen session without stopping the server, use the key combination Ctrl+A, followed by D. The screen session will continue running in the background.

To return to the Minecraft screen session or make any other changes, use the following commands:

List all screen sessions:

screen -list

Go back to your running screen session:

screen -dr MinecraftServer

If you used a different session name, replace "MinecraftServer" with your session name.

Delete the screen session (Note: This will end the Minecraft game):

screen -X -S MinecraftServer quit

Step 6 - Using a Different Port (Optional): By default, Minecraft starts on port 25565. If you want to use a different port, follow these steps:

  1. If you're currently in the Minecraft screen session, use stop to stop the server.

  2. To start a second game on a different port, exit the current screen session using Ctrl+A, D, and create a new session.

  3. Download the Minecraft server JAR file again, save it in a separate directory, and ensure your server has sufficient RAM to host two games.

  4. Open the server.properties file in the same directory as your Minecraft server JAR file:

nano server.properties
  1. Edit the server.properties file to change the port. Locate the line server-port=25565 and change the port number (e.g., server-port=25567).

  2. Save your changes with Ctrl+X, Y, and Enter.

  3. Start a new game on the

Bu cevap yeterince yardımcı oldu mu? 1534 Bu dökümanı faydalı bulan kullanıcılar: (2178 Oy)