Last active 7 months ago

Korbs's Avatar Korbs revised this gist 7 months ago. Go to revision

1 file changed, 113 insertions, 1 deletion

README.md

@@ -1 +1,113 @@
1 - .init
1 + # Selfhosting Minecraft Java Server
2 +
3 + Getting around to selfhosting your own Minecraft Java server has it's perks and gives you full control of your server's data, it's also much more affordable compared to using a SaaS.
4 +
5 + If you have a spare machine laying around that is no longer in use, it would be re-purposed as a Minecraft server.
6 +
7 + ## Hardware Requirements
8 +
9 + For the piece of hardware you'll be using to host the server on, you want to make sure you know it can handle it. For your CPU, it should at least have 4 or more cores over 2GHz. 4GB - 8GB or more RAM(Memory), this also varies how much you add to the server like the amount of players connecting or the many plugins or mods you add. For disk space, I make sure you have at least 8GB or more, this also varies like it does with RAM.
10 +
11 + If you do plan to launch your server publically for many to join, make your internet connection for this machine is decent as well. For this, your upload speed is important, 100Mbps or more for your upload speed should do fine. If it's something like 10Mbps, players may lag a bit every now and then, but if the hardware is stable enough and too much isn't happening, it may keep up just a tad, but not recommended.
12 +
13 + ## Software Requirements
14 + For what operating system the machine should be running, using something like Linux would be preferred as it's much more lightweight and less bloated than Microsoft Windows. If this machine is for server-purpose only, then it should be a server OS, with no GUIs pre-installed, since GUIs like a desktop environment can add onto the RAM and disk space alone.
15 +
16 + For what Linux distro you should use, this shouldn't matter too much for hosting a Minecraft operating system. This tutorials will should steps for at least Debian, RHEL(Fedora/CentOS), and Alpine Linux.
17 +
18 + As for what should be installed on the Linux operating system, you'll need at least Java installed. This will be the first step listed.
19 +
20 + ___
21 +
22 + ## Step 1 - Java Installation
23 +
24 + > We'll use also install `wget`, that'll be used in the next time.
25 +
26 + **Debian/Ubuntu**
27 +
28 + To install Java, run the following commands:
29 + ```bash
30 + apt update
31 + apt install default-jre default-jdk wget
32 + ```
33 +
34 + **RHEL**
35 +
36 + To install Java, run the following:
37 + ```bash
38 + dnf update
39 + dnf install java wget
40 + ```
41 +
42 + **Alpine Linux**
43 +
44 + To install Java, run the following:
45 + ```ash
46 + apk add java wget
47 + ```
48 +
49 + ## Step 2 - Download Minecraft Server Software
50 +
51 + Before we do download the server software, let's first decide on where to put the server. Create a directly for the server, for this tutorial, we'll use the user's home folder.
52 +
53 + To create a directory for the server, which we'll called `mcserver` for this tutorial, run the `mkdir` command:
54 + ```bash
55 + mkdir ~/mcserver/
56 + ```
57 +
58 + Then, use the `cd` command to change directory within the terminal:
59 + ```bash
60 + cd ~/mcserver
61 + ```
62 +
63 + Now, with `wget`, we can use it to download the server software to the server. The server runs simply from a __.jar__ file, as all Minecraft Java servers do, to download it to the folder run the following:
64 + ```bash
65 + wget https://piston-data.mojang.com/v1/objects/e6ec2f64e6080b9b5d9b471b291c33cc7f509733/server.jar
66 + ```
67 +
68 + > The link is pulled from the [official website](https://www.minecraft.net/en-us/download/server), right-click the `.jar` link and copy link to get it. This tutorial was written as of 1.21.5, so the link used in the command is for Minecraft Java 1.21.5.
69 +
70 + This should download the file needed, it should be outputted to the folder now as __server.jar__. You can confirm by running the list files command in the terminal:
71 + ```bash
72 + ls
73 + ```
74 +
75 + If you see the __server.jar__ file, you've successfully downloaded what's needed.
76 +
77 + ## Step 3 - Starting the Server
78 +
79 + To run the server, `java` is used while targetting the __server.jar__ file, we can simply run:
80 + ```bash
81 + java -jar server.jar
82 + ```
83 +
84 + This will run the server, since it's brand new it'll generate the needed files. Since this will be the first run, the server will quit automatically after it generates the __EULA.txt__ file, as you're required to agree to it.
85 +
86 + Edit the __EULA.txt__ file, with `nano` or your preferred terminal editor, and change `false` to `true`.
87 + ```bash
88 + nano EULA.txt
89 + ```
90 +
91 + To save, with `nano`, press `Ctrl` + `O`, then `Enter`. To exit the editor, `Ctrl` + `X`.
92 +
93 + Now, run the first command again and it'l generate the world and the server will be running:
94 + ```bash
95 + java -jar server.jar
96 + ```
97 +
98 + Please note that you should use it like that in production, there are tons of other paremeters that can be added to optimize your Minecraft Java server, use https://flags.sh/ to get an optimize launch command.
99 +
100 + Congrats! If everything went smoothly, your Minecraft Java server is now running.
101 +
102 + ## Step 4 - Joining the Server
103 +
104 + Okay, now we need to figure out how to join the server over your local network(if the server is locally within your home network). We can get the server's IP address and use it to join the server from our Minecraft client(the game itself).
105 +
106 + To retrieve the local IP address of the server, run the following command:
107 + ```bash
108 + ip addr show
109 + ```
110 +
111 + You may see a lot or a few connection in the output, if your server is connected over Ethernet you'll want to look at the `eth0` connection, or it may be called `eth1`. Look for an local IP address that should begin with `192.168.`, this will be your server's local IP address. If it's over WiFi, the connection name beings with `wlp`.
112 +
113 + For this tutorial, we'll pretend that the server's local IP address will be `192.168.1.114`. This means, you can use `192.168.1.114` or `192.168.1.114:25565` to connect to the server in Minecraft.

Korbs's Avatar Korbs revised this gist 7 months ago. Go to revision

1 file changed, 1 insertion

README.md(file created)

@@ -0,0 +1 @@
1 + .init
Newer Older