GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu18.04LTSにMinecraftサーバーをインストールする方法

Minecraftは、MicrosoftStudiousによって開発された世界で最も人気のあるゲームの1つです。 Minecraftはサンドボックスビデオゲームであり、必要なものをすべて作成して3Dの世界で探索することができます。 Minecraftを使用すると、シングルプレイヤーモードだけでなく、友達とオンラインでゲームをプレイできます。 Minecraftは、Linux、macOS、Windowsなどの幅広いプラットフォームで利用できます。

このチュートリアルでは、MinecraftサーバーをUbuntu18.04サーバーにインストールする方法を学習します。

要件
  • Ubuntu18.04を実行しているサーバー。
  • サーバーにルートパスワードが設定されています。
はじめに

開始する前に、システムを最新バージョンに更新する必要があります。これを行うには、次のコマンドを実行します。

apt-get update -y
apt-get upgrade -y

サーバーが更新されたら、サーバーを再起動して変更を適用します。

次に、サーバーにいくつかの依存関係をインストールする必要があります。次のコマンドですべてをインストールできます:

apt-get install git build-essential -y

Javaのインストール

MinecraftはJavaプログラム言語で開発されているので。そのため、サーバーにJavaDevelopmentKitまたはJREをインストールする必要があります。次のコマンドでJavaをインストールできます。

apt-get install openjdk-8-jre-headless -y

インストールしたら、次のコマンドを使用してJavaを確認します。

java -version

次の出力が得られるはずです:

openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

Minecraftサーバーのインストールと構成

まず、Minecraftサーバーを実行するためのユーザーを作成する必要があります。次のコマンドで作成できます:

useradd -r -m -U -d /home/minecraft -s /bin/bash minecraft

次に、次のコマンドを使用してminecraftユーザーにログインします。

su - minecraft

次に、次のコマンドを使用して、minecraftに必要なディレクトリを作成します。

mkdir backups tools server

次に、ディレクトリを〜/ toolsディレクトリに変更し、Gitリポジトリからmcrconをダウンロードします。

cd ~/tools
git clone https://github.com/Tiiffi/mcrcon.git

次に、ディレクトリをmcrconに変更し、次のコマンドを使用してmcrconをコンパイルします。

cd mcrcon
gcc -std=gnu11 -pedantic -Wall -Wextra -O2 -s -o mcrcon mcrcon.c

次の出力が表示されます。

mcrcon.c: In function ‘get_line’:
mcrcon.c:752:2: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
  (void) fgets(buffer, bsize, stdin);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

次に、ディレクトリを〜/ serverに変更し、次のコマンドを使用して最新のMojangの公式バニラMinecraftサーバーをダウンロードします。

cd ~/server
wget https://launcher.mojang.com/v1/objects/3dc3d84a581f14691199cf6831b71ed1296a9fdf/server.jar

ダウンロードが完了したら、次のコマンドでMinecraftサーバーを起動します。

java -Xmx1024M -Xms512M -jar server.jar nogui

次のエラーが発生するはずです:

[06:00:45] [main/ERROR]: Failed to load properties from file: server.properties
[06:00:48] [main/WARN]: Failed to load eula.txt
[06:00:48] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

このエラーを解決するには、サーバーを実行するためにMinecraftEULAに同意する必要があります。

これを行うには、eula.txtファイルを開きます:

nano eula.txt

以下に示すように、eula=falseをeula=trueに変更します。

eula=true

ファイルを保存して閉じます。次に、server.propertiesファイルを開いてrconプロトコルを有効にし、rconパスワードを設定します。

nano server.properties

次の行を変更します:

rcon.port=25575
[email protected]
enable-rcon=true

終了したら、ファイルを保存して閉じます。次に、次のコマンドを使用してMinecraftユーザーを終了します。

exit

MinecraftのSystemdサービスファイルを作成する

次に、Minecraftサービスを管理するためのsystemdサービスファイルを作成する必要があります。次のコマンドで作成できます:

nano /etc/systemd/system/minecraft.service

次の行を追加します:

[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/server
ExecStart=/usr/bin/java -Xmx1024M -Xms512M -jar server.jar nogui
ExecStop=/home/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p [email protected] stop

[Install]
WantedBy=multi-user.target

ファイルを保存して閉じます。次に、次のコマンドを使用してsystemdデーモンをリロードします。

systemctl daemon-reload

次に、Minecraftサービスを開始し、次のコマンドを使用してシステムの再起動後に開始できるようにします。

systemctl start minecraft
systemctl enable minecraft

次のコマンドを使用して、Minecraftサービスのステータスを確認することもできます。

systemctl status minecraft

次の出力が得られるはずです:

? minecraft.service - Minecraft Server
   Loaded: loaded (/etc/systemd/system/minecraft.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-10-07 06:33:32 UTC; 6s ago
 Main PID: 4318 (java)
    Tasks: 34 (limit: 4915)
   CGroup: /system.slice/minecraft.service
           ??4318 /usr/bin/java -Xmx1024M -Xms512M -jar server.jar nogui

Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Loading properties
Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Default game type: SURVIVAL
Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Generating keypair
Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Starting Minecraft server on *:25565
Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Using epoll channel type
Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Preparing level "world"
Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Found new data pack vanilla, loading it automatically
Oct 07 06:33:37 ubuntu1804 java[4318]: [06:33:37] [Server thread/INFO]: Reloading ResourceManager: Default
Oct 07 06:33:38 ubuntu1804 java[4318]: [06:33:38] [Server thread/INFO]: Loaded 6 recipes
Oct 07 06:33:38 ubuntu1804 java[4318]: [06:33:38] [Server thread/INFO]: Loaded 811 advancements
テストMinecraft

これで、Minecraftサーバーがインストールされて実行されます。それをテストする時が来ました。

ターミナルを開き、以下に示すように、mcrconユーティリティを使用してMinecraftコンソールにアクセスします。

/home/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25575 -p [email protected] -t

接続すると、次の出力が得られます。

Logged in. Type "Q" to quit!
>

おめでとう!これで、Ubuntu18.04サーバーにMinecraftサーバーが正常にインストールおよび構成されました。ご不明な点がございましたら、お気軽にお問い合わせください。


Ubuntu
  1. Ubuntu18.04にMinecraftサーバーをインストールする方法

  2. Ubuntu20.04LTSにMinecraftサーバーをインストールする方法

  3. Ubuntu20.04LTSにDiscourseをインストールする方法

  1. Ubuntu20.04にSpigotMinecraftサーバーをインストールする方法

  2. Ubuntu Server18.04LTSのインストール方法

  3. Ubuntu18.04LTSサーバーにDockerをインストールする方法

  1. Ubuntu20.04LTSサーバーをインストールする方法

  2. Ubuntu18.04LTSサーバーにDropboxをインストールする方法

  3. Ubuntu22.04LTSにWebfsサーバーをインストールする方法