如何搭建“我的世界”服务器
游戏 Minecraft
![](/data/attachment/album/201803/25/222913j0pbnyvnoyo11231.jpg)


我们将通过一个一步步的、新手友好的教程来向你展示如何搭建一个“我的世界（Minecraft）”服务器。这将会是一个长期的多人游戏服务器，你可以与来自世界各地的朋友们一起玩，而不用在同一个局域网下。


### 如何搭建一个“我的世界”服务器 - 快速指南


在你开始行动之前，要先了解一些事情：


#### 为什么你**不**应该使用专门的“我的世界”服务器提供商


既然你正在阅读这篇文章，你肯定对搭建自己的“我的世界”服务器感兴趣。不应该使用专门的“我的世界”服务器提供商的原因有很多，以下是其中一些：


* 它们通常很慢。这是因为你是在和很多用户一起共享资源。这有的时候会超负荷，他们中很多都会超售。
* 你并不能完全控制“我的世界”服务端或真正的服务器。你没法按照你的意愿进行自定义。
* 你是受限制的。这种主机套餐或多或少都会有限制。


当然，使用现成的提供商也是有优点的。最好的就是你不用做下面这些操作。但是那还有什么意思呢？!


#### 为什么不应该用你的个人电脑作为“我的世界”服务器


我们注意到很多教程都展示的是如何在你自己的电脑上搭建服务器。这样做有一些弊端，比如：


* 你的家庭网络不够安全，无法抵挡 DDoS 攻击。游戏服务器通常容易被 DDoS 攻击，而你的家庭网络设置通常不够安全，来抵挡它们。很可能连小型攻击都无法阻挡。
* 你得处理端口转发。如果你试着在家庭网络中搭建“我的世界”服务器的话，你肯定会偶然发现端口转发的问题，并且处理时可能会有问题。
* 你得保持你的电脑一直开着。你的电费将会突破天际，并且你会增加不必要的硬件负载。大部分服务器硬件都是企业级的，提升了稳定性和持久性，专门设计用来处理负载。
* 你的家庭网络速度不够快。家庭网络并不是设计用来负载多人联机游戏的。即使你想搭建一个小型服务器，你也需要一个更好的网络套餐。幸运的是，数据中心有多个高速的、企业级的互联网连接，来保证他们达到（或尽量达到）100%在线。
* 你的硬件很可能不够好。再说一次，服务器使用的都是企业级硬件，最新最快的处理器、固态硬盘，等等。你的个人电脑很可能不是的。
* 你的个人电脑很可能是 Windows/MacOS。尽管这有所争议，但我们相信 Linux 更适合搭建游戏服务器。不用担心，搭建“我的世界”服务器不需要完全了解 Linux（尽管推荐这样）。我们会向你展示你需要了解的。


我们的建议是不要使用个人电脑，即使从技术角度来说你能做到。买一个云服务器并不是很贵。下面我们会向你展示如何在云服务器上搭建“我的世界”服务端。小心地遵守以下步骤，就很简单。


### 搭建一个“我的世界”服务器 - 需求


这是一些需求，你在教程开始之前需要拥有并了解它们：


* 你需要一个 [Linux 云服务器](https://thishosting.rocks/cheap-cloud-hosting-providers-comparison/)。我们推荐 [Vultr](https://thishosting.rocks/go/vultr/)。这家价格便宜，服务质量高，客户支持很好，并且所有的服务器硬件都很高端。检查[“我的世界”服务器需求](https://minecraft.gamepedia.com/Server/Requirements/Dedicated)来选择你需要哪种类型的服务器（像内存和硬盘之类的资源）。我们推荐每月 20 美元的套餐。他们也支持按小时收费，所以如果你只是临时需要服务器和朋友们联机的话，你的花费会更少。注册时选择 Ubuntu 16.04 发行版。在注册时选择离你的朋友们最近的地域。这样的话你就需要保护并管理服务器。如果你不想这样的话，你可以选择[托管的服务器](https://thishosting.rocks/best-cheap-managed-vps/)，这样的话服务器提供商可能会给你搭建好一个“我的世界”服务器。
* 你需要一个 SSH 客户端来连接到你的 Linux 云服务器。新手通常建议使用 [PuTTy](https://www.chiark.greenend.org.uk/%7Esgtatham/putty/)，但我们也推荐使用 [MobaXTerm](https://mobaxterm.mobatek.net/)。也有很多 SSH 客户端，所以挑一个你喜欢的吧。
* 你需要设置你的服务器（至少做好基本的安全设置）。谷歌一下你会发现很多教程。你也可以按照 [Linode 的 安全指南](https://www.linode.com/docs/security/securing-your-server/)，然后在你的 [Vultr](https://thishosting.rocks/go/vultr/) 服务器上一步步操作。
* 下面我们将会处理软件依赖，比如 Java。


终于，到我们真正的教程了：


### 如何在 Ubuntu（Linux）上搭建一个“我的世界”服务器


这篇教程是为 [Vultr](https://thishosting.rocks/go/vultr/) 上的 Ubuntu 16.04 撰写并测试可行的。但是这对 Ubuntu 14.04， [Ubuntu 18.04](https://thishosting.rocks/ubuntu-18-04-new-features-release-date/)，以及其他基于 Ubuntu 的发行版、其他服务器提供商也是可行的。


我们使用默认的 Vanilla 服务端。你也可以使用像 CraftBukkit 或 Spigot 这样的服务端，来支持更多的自定义和插件。虽然如果你使用过多插件的话会影响服务端。这各有优缺点。不管怎么说，下面的教程使用默认的 Vanilla 服务端，来使事情变得简单和更新手友好。如果有兴趣的话我们可能会发表一篇 CraftBukkit 的教程。


#### 1. 登录到你的服务器


我们将使用 root 账户。如果你使用受限的账户的话，大部分命令都需要 `sudo`。做你没有权限的事情时会出现警告。


你可以通过 SSH 客户端来登录你的服务器。使用你的 IP 和端口（大部分都是 22）。


在你登录之后，确保你的[服务器安全](https://www.linode.com/docs/security/securing-your-server/)。


#### 2. 更新 Ubuntu


在你做任何事之前都要先更新你的 Ubuntu。你可以通过以下命令更新：



```
apt-get update && apt-get upgrade

```

在提示时敲击“回车键” 和/或 `y`。


#### 3. 安装必要的工具


在这篇教程中你需要一些工具和软件来编辑文本、长久保持服务端运行等。使用下面的命令安装：



```
apt-get install nano wget screen bash default-jdk ufw

```

其中一些可能已经安装好了。


#### 4. 下载“我的世界”服务端


首先，创建一个目录来保存你的“我的世界”服务端和其他文件：



```
mkdir /opt/minecraft

```

然后进入新目录：



```
cd /opt/minecraft

```

现在你可以下载“我的世界“服务端文件了。去往[下载页面](https://minecraft.net/en-us/download/server)获取下载链接。使用 `wget` 下载文件：



```
wget https://s3.amazonaws.com/Minecraft.Download/versions/1.12.2/minecraft_server.1.12.2.jar

```

#### 5. 安装“我的世界”服务端


下载好了服务端的 .jar 文件之后，你就需要先运行一下，它会生成一些文件，包括一个 `eula.txt` 许可文件。第一次运行的时候，它会返回一个错误并退出。这是正常的。使用下面的命令运行它：



```
java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.2.jar nogui

```

`-Xms2048M` 是你的服务端能使用的最小的内存，`-Xmx3472M` 是最大的内存。[调整](https://minecraft.gamepedia.com/Commands)基于你服务器的硬件资源。如果你在 [Vultr](https://thishosting.rocks/go/vultr/) 服务器上有 4GB 内存，并且不用服务器来干其他事情的话可以就这样留着不动。


在这条命令结束并返回一个错误之后，将会生成一个新的 `eula.txt` 文件。你需要同意那个文件里的协议。你可以通过下面这条命令将 `eula=true` 添加到文件中：



```
sed -i.orig 's/eula=false/eula=true/g' eula.txt

```

你现在可以通过和上面一样的命令来开启服务端并进入“我的世界”服务端控制台了：



```
java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.2.jar nogui

```

确保你在 `/opt/minecraft` 目录，或者其他你安装你的 MC 服务端的目录下。


如果你只是测试或暂时需要的话，到这里就可以停了。如果你在登录服务器时有问题的话，你就需要[配置你的防火墙](https://thishosting.rocks/how-to-make-a-minecraft-server/#configure-minecraft-server)。


第一次成功启动服务端时会花费一点时间来生成。


我们将向你展示如何创建一个脚本来启动。


#### 6. 使用脚本启动“我的世界”服务端，让服务端长期运行并在启动时开启


方便起见，我们将创建一个自动启动服务端的 bash 脚本。


首先，使用 nano 创建一个 bash 脚本：



```
nano /opt/minecraft/startminecraft.sh

```

这将会打开一个新的（空白）文件。粘贴以下内容：



```
#!/bin/bash
cd /opt/minecraft/ && java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.2.jar nogui

```

如果你不熟悉 nano 的话 - 你可以使用 `CTRL + X`，再敲击 `Y`，然后回车。这个脚本将进入你先前创建的“我的世界”服务端并运行 Java 命令来开启服务端。你需要执行下面的命令来使脚本可执行：



```
chmod +x startminecraft.sh

```

然后，你就可以通过下面的命令随时运行服务端了：



```
/opt/minecraft/startminecraft.sh

```

但是，如果/当你登出 SSH 会话的话，服务端就会关闭。要想让服务端不登录也持续运行的话，你可以使用 `screen` 会话。`screen` 会话会一直运行，直到实际的服务器被关闭或重启。


使用下面的命令开启一个 screen 会话：



```
screen -S minecraft

```

一旦你进入了 `screen` 会话（看起来就像是你新建了一个 SSH 会话），你就可以使用先前创建的 bash 脚本来启动服务端：



```
/opt/minecraft/startminecraft.sh

```

要退出 `screen` 会话的话，你应该按 `CTRL+A-D`。即使你离开 `screen` 会话（断开的），服务端也会继续运行。你现在可以安全的登出 Ubuntu 服务器了，你创建的“我的世界”服务端将会继续运行。


但是，如果 Ubuntu 服务器重启或关闭了的话，`screen` 会话将不再起作用。所以**为了让我们之前做的这些在启动时自动运行**，做下面这些：


打开 `/etc/rc.local` 文件：



```
nano /etc/rc.local

```

在 `exit 0` 语句前添加如下内容：



```
screen -dm -S minecraft /opt/minecraft/startminecraft.sh
exit 0

```

保存并关闭文件。


要访问“我的世界”服务端控制台，只需运行下面的命令来重新连接 `screen` 会话：



```
screen -r minecraft

```

现在就是这样。祝贺你，玩的开心！你现在可以连接到你的“我的世界”服务端或配置/修改它了。


### 配置你的 Ubuntu 服务器


你首先肯定要设置并确保你的 Ubuntu 服务器安全，如果你还没有这么做的话。按照[我们之前提及的指南](https://www.linode.com/docs/security/securing-your-server/)并谷歌一下来获取更多信息。你需要在服务器上配置的有这些：


#### 开启并配置防火墙


首先，如果防火墙还没有开启的话，你应该先开启先前安装的 UFW：



```
ufw enable

```

你应该开放默认的“我的世界”服务端端口：



```
ufw allow 25565/tcp

```

你应该根据你的使用情况开放或拒绝其他规则。如果你不用服务器负载网站的话，就应该拒绝 80 和 443 端口。谷歌一下 Ubuntu 的 UFW/防火墙指南，你会得到建议的。设置防火墙的时候小心一些，如果你屏蔽了 SSH 端口的话你会把自己锁在服务器外面。


由于这是默认端口，这个端口经常被扫描以及攻击。你可以通过屏蔽白名单之外的访问权限来阻挡攻击。


首先，你需要在你的 [server.properties](https://minecraft.gamepedia.com/Server.properties) 文件中开启白名单模式。要开启的话，打开文件：



```
nano /opt/minecraft/server.properties

```

并将 `white-list` 行改为 `true`：



```
white-list=true

```

保存并关闭文件。


然后重启你的服务器（重启你的服务器或重新运行启动脚本）：



```
/opt/minecraft/startminecraft.sh

```

访问“我的世界”服务端控制台：



```
screen -r minecraft

```

如果你想要某人进入你的服务端，你需要通过以下命令把他们添加到白名单：



```
whitelist add PlayerUsername

```

运行以下命令来将他们移出白名单：



```
whitelist remove PlayerUsername

```

使用 `CTRL+A-D` 来退出 `screen`（服务器控制台）。值得注意的是，这会拒绝除白名单以外的所有人连接到服务端。


### 如何搭建“我的世界”服务器 - 常见问题


我们将解答一些有关“我的世界”服务器和我们的指南的常见问题。


#### 我该如何重启“我的世界”服务器？


如果你按照我们的教程来的话，包括开启了服务端随系统启动，你可以直接重启你的 Ubuntu 服务器。如果没有设置岁系统启动的话，你可以通过重新运行启动脚本来重启“我的世界”服务端：



```
/opt/minecraft/startminecraft.sh

```

#### 我该如何配置我的“我的世界”服务端？


你可以使用 [server.properties](https://minecraft.gamepedia.com/Server.properties) 文件来配置你的服务端。查看“我的世界”维基来获取更多信息，你也可以什么都不动，它会工作的很好。


如果你想改变游戏模式、难度等诸如此类的东西，你可以使用服务端控制台。通过下面的命令访问服务端控制台：



```
screen -r minecraft

```

并执行[命令](https://minecraft.gamepedia.com/Commands)。像下面这些命令：



```
difficulty hard

```


```
gamemode survival @a

```

你可能需要重新启动服务端，这取决于你使用了什么命令。你可以使用很多命令，查看[维基](https://minecraft.gamepedia.com/Commands)来获取更多。


#### 我该如何升级我的“我的世界”服务端？


如果有新版本发布的话，你需要这样做：


进入“我的世界”目录：



```
cd /opt/minecraft

```

下载最新的版本，比如使用 wget 下载 1.12.3 版本：



```
wget https://s3.amazonaws.com/Minecraft.Download/versions/1.12.3/minecraft_server.1.12.3.jar

```

接下来，运行并构建新服务端：



```
java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.3.jar nogui

```

最后，更新你的启动脚本：



```
nano /opt/minecraft/startminecraft.sh

```

更新版本号数字：



```
#!/bin/bash
cd /opt/minecraft/ && java -Xms2048M -Xmx3472M -jar minecraft_server.1.12.3.jar nogui

```

现在你可以重启服务端了，一切都应该没有问题。


#### 为什么你们的教程这么长，而其他的只有 2 行那么长？！


我们想让这个教程对新手来说更友好，并且尽可能详细。我们还向你展示了如何让服务端长期运行并跟随系统启动，我们向你展示了如何配置你的服务端以及所有的东西。我是说，你当然可以用几行来启动“我的世界”服务器，但那样的话绝对很烂，从不仅一方面说。


#### 我不知道 Linux 或者这里说的什么东西，我该如何搭建一个“我的世界”服务器呢？


只要通篇阅读我们的文章，复制粘贴几个命令就行了。如果你真的不知道该如何做的话，[我们可以帮你](https://thishosting.rocks/support/)，或者直接找一个[托管的](https://thishosting.rocks/best-cheap-managed-vps/)服务器[提供商](https://thishosting.rocks/best-cheap-managed-vps/)，让他们帮你做这些。


#### 我该如何在服务端上安装 mod 和插件？


我们的文章意图作一篇入门指南，你应该查看[“我的世界维基”](https://minecraft.gamepedia.com/Minecraft_Wiki)，或者谷歌一下来获取更多信息。网上有很多教程。




---


via: <https://thishosting.rocks/how-to-make-a-minecraft-server/>


作者：[ThisHosting.Rocks](https://thishosting.rocks) 译者：[heart4lor](https://github.com/heart4lor) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
We’ll show you how to make a Minecraft server with beginner-friendly step-by-step instructions. It will be a persistent multiplayer server that you can play on with your friends from all around the world. You don’t have to be in a LAN.


## How to Make a Minecraft Server – Quick Guide

This is our “Table of contents” if you’re in a hurry and want to go straight to the point. We recommend reading everything though.

[Learn stuff](#reasons)(optional)[Learn more stuff](#not-pc)(optional)[Requirements](#requirements)(required)[Install and start the Minecraft server](#make-minecraft-server)(required)[Run the server even after you log out of your VPS](#persistent)(optional)[Make the server automatically start at boot](#boot)(optional)[Configure your Minecraft server](#configure-minecraft-server)(required)[FAQs](#faqs)(optional)

Need specialized managed Minecraft server hosting? Get server from

[Surf Hosting]

Before going into the actual instructions, a few things you should know:

## Reasons why you would NOT use a specialized Minecraft server hosting provider

Since you’re here, you’re obviously interested in hosting your own Minecraft server. There are more reasons why you would not use a specialized Minecraft hosting provider, but here are a few:

**They’re slow most of the time**. This is because you actually share the resources with multiple users. It becomes overloaded at some point. Most of them oversell their servers too.**You don’t have full control**over the Minecraft server or the actual server. You cannot customize anything you want to.**You’re limited.**Those kinds of hosting plans are always limited in one way or another.

Of course, there are positives to using a Minecraft hosting provider. The best upside is that you don’t actually have to do all the stuff we’ll write about below. But where’s the fun in that? 🙂

## Why you should NOT use your personal computer to make a Minecraft server

We noticed lots of tutorials showing you how to host a server on your own computer. There are downsides to doing that, like:

**Your home internet is not secured enough**to handle DDoS attacks. Game servers are often prone to DDoS attacks, and your home network setup is most probably not secured enough to handle them. It’s most likely not powerful enough to handle a small attack.**You’ll need to handle port forwarding.**If you’ve tried making a Minecraft server on your home network, you’ve surely stumbled upon port forwarding and had issues with it.**You’ll need to keep your computer on at all times.**Your electricity bill will sky-rocket and you’ll add unnecessary load to your hardware. The hardware most servers use is enterprise-grade and designed to handle loads, with improved stability and longevity.**Your home internet is not fast enough**. Home networks are not designed to handle multiplayer games. You’ll need a much larger internet plan to even consider making a small server. Luckily, data centers have multiple high-speed, enterprise-grade internet connections making sure they have (or strive to have) 100% uptime.**Your hardware is most likely not good enough**. Again, servers use enterprise-grade hardware, latest and fastest CPUs, SSDs, and much more. Your personal computer most likely does not.- You probably use Windows/MacOS on your personal computer. Though this is debatable, we believe that
**Linux is much better for game hosting**. Don’t worry, you don’t really need to know everything about Linux to make a Minecraft server (though it’s recommended). We’ll show you everything you need to know.

Our tip is not to use your personal computer, though technically you can. It’s not expensive to buy a cloud server. We’ll show you how to make a Minecraft server on cloud hosting below. It’s easy if you carefully follow the steps.

## Making a Minecraft Server – Requirements

There are a few requirements. You should have and know all of this before continuing to the tutorial:

**You’ll need a**. We recommend[Linux cloud server](https://thishosting.rocks/cheap-cloud-hosting-providers-comparison/)[Linode](https://thishosting.rocks/go/linode/). Their prices are cheap, services are high-quality, customer support is great, all server hardware is high-end. Check the[Minecraft server requirements](https://minecraft.gamepedia.com/Server/Requirements/Dedicated)to find out what kind of server you should get (resources like RAM and Disk space). We recommend getting the $20 per month server. They support hourly pricing so if you only need the server temporary for playing with friends, you’ll pay less. Choose the[Ubuntu 22.04](https://thishosting.rocks/ubuntu-22-04-release-date-whats-new/)distro during signup. Choose the closest server location to where your players live during the signup process. Keep in mind that you’ll be responsible for your server. So you’ll have to secure it and manage it. If you don’t want to do that, you can get a[managed server](https://thishosting.rocks/best-cheap-managed-vps/), in which case the[hosting provider](https://thishosting.rocks/best-game-server-hosting/)will likely make a Minecraft server for you.**You’ll need an SSH client**to connect to the Linux cloud server.[PuTTy](https://www.chiark.greenend.org.uk/~sgtatham/putty/)is often recommended for beginners, but we also recommend[MobaXTerm](https://mobaxterm.mobatek.net/). There are many other SSH clients to choose from, so pick your favorite.**You’ll need to setup your server**(basic security setup at least). Google it and you’ll find many tutorials. You can use[Linode’s Security Guide](https://www.linode.com/docs/security/securing-your-server/)and follow the exact steps on your[Linode](https://thishosting.rocks/go/linode/)server.- We’ll handle the software requirements like Java below.

And finally, onto our actual tutorial:

## How to Make a Minecraft Server on Ubuntu (Linux)

These instructions are written for and tested on an Ubuntu 22.04 server from [Linode](https://thishosting.rocks/go/linode/). Though they’ll also work on [Ubuntu 20.04](https://thishosting.rocks/ubuntu-20-04-release-date-features-more/), [Ubuntu 18.04](https://thishosting.rocks/ubuntu-18-04-new-features-release-date/), and any other Ubuntu-based distro, and any other server provider.

We’re using the default **Vanilla server** from Minecraft. You can use alternatives like CraftBukkit or Spigot that allow more customizations and plugins. Though if you use too many plugins you’ll essentially ruin the server. There are pros and cons to each one. Nevertheless, the instructions below are for the default Vanilla server to keep things simple and beginner-friendly. We may publish a tutorial for CraftBukkit soon if there’s an interest.

Here are the step-by-step instructions on how to make a Minecraft server:





### 1. Login to your server

We’ll use the root user. If you use a limited-user, you’ll have to execute most commands with ‘sudo’. You’ll get a warning if you’re doing something you don’t have enough permissions for.

You can login to your server via your SSH client. Use your server IP and your port (most likely 22).

After you log in, make sure you [secure your server](https://www.linode.com/docs/security/securing-your-server/).

### 2. Update Ubuntu

You should always first update your Ubuntu before you do anything else. You can update it with the following commands:

apt-get update && apt-get upgrade

Hit “enter” and/or “y” when prompted.

### 3. Install necessary tools

You’ll need a few packages and tools for various things in this tutorial like text editing, making your server persistent etc. Install them with the following command:

apt-get install nano wget screen bash default-jdk ufw

Some of them may already be installed.

### 4. Download Minecraft Server

First, create a directory where you’ll store your Minecraft server and all other files:

mkdir /opt/minecraft

And navigate to the new directory:

cd /opt/minecraft

Now you can download the Minecraft Server file. Go to the [download page](https://minecraft.net/en-us/download/server) and get the link there. Download the file with wget:

wget https://launcher.mojang.com/v1/objects/125e5adf40c659fd3bce3e66e67a16bb49ecc1b9/server.jar

### 5. Install the Minecraft server

Once you’ve downloaded the server .jar file, you need to run it once and it will generate some files, including an eula.txt license file. The first time you run it, it will return an error and exit. That’s supposed to happen. Run in with the following command:

java -Xms2048M -Xmx3472M -jar server.jar nogui

“-Xms2048M” is the minimum RAM that your Minecraft server can use and “-Xmx3472M” is the maximum. [Adjust](https://minecraft.gamepedia.com/Commands) this based on your server’s resources. If you got the 4GB RAM server from [Linode](https://thishosting.rocks/go/linode/) you can leave them as-is, if you don’t use the server for anything else other than Minecraft.

**After that command ends and returns an error**, a new eula.txt file will be generated. You need to accept the license in that file. You can do that by adding “eula=true” to the file with the following command:

sed -i.orig 's/eula=false/eula=true/g' eula.txt

You can now start the server again and access the Minecraft server console with that same java command from before:

java -Xms2048M -Xmx3472M -jar server.jar nogui

Make sure you’re in the /opt/minecraft directory, or the directory where you installed your MC server.

You’re free to stop here if you’re just testing this and need it for the short-term. If you’re having trouble loggin into the server, you’ll need to [configure your firewall](#configure-minecraft-server).

The first time you successfully start the server it will take a bit longer to generate

We’ll show you how to create a script so you can start the server with it.

### 6. Start the Minecraft server with a script, make it persistent, and enable it at boot

To make things easier, we’ll create a bash script that will **start the server automatically**.

So first, create a bash script with nano:

nano /opt/minecraft/startminecraft.sh

A new (blank) file will open. Paste the following:

#!/bin/bash cd /opt/minecraft/ && java -Xms2048M -Xmx3472M -jar server.jar nogui

If you’re new to nano – you can save and close the file with “CTRL + X”, then “Y”, and hitting enter. This script navigates to your Minecraft server directory you created previously and runs the java command for starting the server. You need to make it executable with the following command:

chmod +x startminecraft.sh

Then, you can start the server anytime with the following command:

/opt/minecraft/startminecraft.sh

Start a screen session with this command:

screen -S minecraft

Once you’re in the screen session (looks like you would start a new ssh session), you can use the bash script from earlier to start the server:

/opt/minecraft/startminecraft.sh

To get out of the screen session, you should press CTRL + A-D. Even after you get out of the screen session (detach), **the server will keep running**. You can safely log off your Ubuntu server now, and the Minecraft server you created will keep running.

**to do everything we did before automatically at boot**, do the following:

Open the /etc/rc.local file:

nano /etc/rc.local

and add the following line above the “exit 0” line:

screen -dm -S minecraft /opt/minecraft/startminecraft.sh exit 0

Save and close the file.

To access the Minecraft server console, just run the following command to attach to the screen session:

screen -r minecraft

**That’s it for now.** Congrats and have fun! You can now connect to your Minecraft server or configure/modify it.

## Configure your Ubuntu Server

You’ll, of course, need to set up your Ubuntu server and secure it if you haven’t already done so. Follow the [guide we mentioned earlier](https://www.linode.com/docs/security/securing-your-server/) and google it for more info. The configurations you need to do for your Minecraft server on your Ubuntu server are:

### Enable and configure the firewall

First, if it’s not already enabled, you should enable UFW that you previously installed:

ufw enable

You should allow the default Minecraft server port:

ufw allow 25565/tcp

You should allow and deny other rules depending on how you use your server. You should deny ports like 80 and 443 if you don’t use the server for hosting websites. Google a UFW/Firewall guide for Ubuntu and you’ll get recommendations. Be careful when setting up your firewall, you may lock yourself out of your server if you block the SSH port.

Since this is the default port, it often gets automatically scanned and attacked. You can prevent attacks by **blocking access to anyone that’s not of your whitelist**.

First, you need to enable the whitelist mode in your [server.properties](https://minecraft.gamepedia.com/Server.properties) file. To do that, open the file:

nano /opt/minecraft/server.properties

And change “white-list” line to “true”:

white-list=true

Save and close the file.

Then restart your server (either by restarting your Ubuntu server or by running the start bash script again):

/opt/minecraft/startminecraft.sh

Access the Minecraft server console:

screen -r minecraft

And if you want someone to be able to join your server, you need to add them to the whitelist with the following command:

whitelist add PlayerUsername

To remove them from the whitelist, use:

whitelist remove PlayerUsername

Exit the screen session (server console) with CTRL + A-D. It’s worth noting that this will deny access to everyone but the whitelisted usernames.

## How to Make a Minecraft Server – FAQs

We’ll answer some frequently asked questions about Minecraft Servers and our guide.

### How do I restart the Minecraft server?

If you followed every step from our tutorial, including enabling the server to start on boot, you can just reboot your Ubuntu server. If you didn’t set it up to start at boot, you can just run the start script again which will restart the Minecraft server:

/opt/minecraft/startminecraft.sh

### How do I configure my Minecraft server?

You can configure your server using the [server.properties](https://minecraft.gamepedia.com/Server.properties) file. Check the Minecraft Wiki for more info, though you can leave everything as-is and it will work perfectly fine.

If you want to change the **game mode, difficulty** and stuff like that, you can use the server console. Access the server console by running:

screen -r minecraft

And execute [commands](https://minecraft.gamepedia.com/Commands) there. Commands like:

difficulty hard

gamemode survival @a

You may need to restart the server depending on what command you used. There are many more commands you can use, check the [wiki](https://minecraft.gamepedia.com/Commands) for more.

### How do I upgrade my Minecraft server?

If there’s a new release, you need to do this:

Navigate to the minecraft directory:

cd /opt/minecraft

Download the latest version with wget (like the step from the beginning of the tutorial)

wget https://launcher.mojang.com/v1/objects/125e5adf40c659fd3bce3e66e67a16bb49ecc1b9/server.jar

Next, run and build the new server:

java -Xms2048M -Xmx3472M -jar server.jar nogui

Finally, update your start script:

nano /opt/minecraft/startminecraft.sh

And update the version number accordingly:

#!/bin/bash cd /opt/minecraft/ && java -Xms2048M -Xmx3472M -jar server.jar nogui

Now you can restart the server and everything should go well.

### Why is your Minecraft server tutorial so long, and yet others are only 2 lines long?!

We tried to make this beginner-friendly and be as detailed as possible. We also showed you how to make the Minecraft server persistent and start it automatically at boot, we showed you how to configure your server and everything. I mean, sure, you can start a Minecraft server with a couple of lines, but it would definitely suck, for more than one reason.

### I don’t know Linux or anything you wrote about here, how do I make a Minecraft server?

Just read all of our article and copy and paste the commands. If you really don’t know how to do it all, [we can do it for you](https://thishosting.rocks/support/), or just get a [managed server provider](https://thishosting.rocks/best-cheap-managed-vps/) and let them do it for you.

### How do I install mods on my server? How do I install plugins?

Our article is intended to be a starting guide. You should check the [Minecraft wiki](https://minecraft.gamepedia.com/Minecraft_Wiki) for more info, or just google it. There are plenty of tutorials online.

### Any other questions?

Leave a comment below and we’ll reply ASAP.

In the meantime, you can read other content:


## 5 thoughts on “How to Make a Minecraft Server”

Hello, how can I set up more RAM for server. I have 30GB but if I set more than you it doesnt work.

Hello

Is setting up a white-list the only way to secure the server from attacks?

You talked about a default port, isn’t there way to protect it?

Thank you very much, the tutorial was great!

After following your tutorial, on my iPad I get “Unable to connect to world”

Minecraft on ipads use a bedrock minecraft client. This is different from the java minecraft server which is installed here. Bedrock clients cannot connect to a java server.

Hi,

How can I resolve the problem having two MC servers on one machine with different java versions and wanting them to run at the same time (Ubuntu)? Is there a start script to define which java version a server has to use?