banner
「The Nanami」

「The Nanami」

游戏宅的自我介绍
github
bilibili
steam

Setting up your Minecraft server on Linux

Preface · Linux Server is not that difficult#

Windows Server, as the most mature GUI server system, is loved by many Minecraft server owners. However, it has a high system occupancy rate and complex functions, and is not very suitable for long-term use as a server system. Linux system has a low occupancy rate and does not require server restart for upgrades and maintenance, which is very convenient. New server owners may be discouraged by the Linux CLI, and this guide aims to help you use Linux Server to build a Minecraft server.

Preparations#

System Selection

If there are no special environmental requirements, mainstream distributions can meet the requirements. This guide uses Ubuntu Server 22.04 LTS as the system version.

Software Preparation

SSH connection tool for communicating with the server, FTP tool (optional).

Text Formatting

~$ will be added before Bash commands to indicate that this line is a Bash command. If not added, it is command line output. Adding # indicates that this line is a comment for the previous line.

Installation Environment#

Install Java1#

~$ sudo apt install openjdk-19-jdk

Verify Java installation

~$ java --version
openjdk 19.0.1 2022-10-18
OpenJDK Runtime Environment (build 19.0.1+10-Ubuntu-1ubuntu122.04)
OpenJDK 64-Bit Server VM (build 19.0.1+10-Ubuntu-1ubuntu122.04, mixed mode, sharing)

Install LNMP Environment (optional)#

Because my server requires plugins that use MySQL, and I'm too lazy to manually configure phpMyAdmin, I use the LNMP environment to solve it all at once. If you have similar requirements, you can also install MySQL and configure it manually. This article does not go into detail.

# Use lnmp.org's unattended installation script
~$ sudo apt install screen
# Install screen to ensure that the process is not killed by the system and can be returned to the terminal to check the status at any time
~$ screen -S lnmp
~$ su
# Use the root user. If you have not set the root user password, use the sudo passwd root command to set it
# Do not always operate as the root user, as it may pose security risks
~$ wget http://soft.vpser.net/lnmp/lnmp1.9.tar.gz -cO lnmp1.9.tar.gz && tar zxf lnmp1.9.tar.gz && cd lnmp1.9 && LNMP_Auto="y" DBSelect="4" Bin="y" DB_Root_Password="<Database Root User Password>" InstallInnodb="y" PHPSelect="12" SelectMalloc="2" ./install.sh lnmp
# Install using the unattended installation command generated by lnmp.org. Do not directly copy and use the command here!!!
Install lnmp takes 13 minutes.
Install lnmp V1.9 completed! enjoy it.
~$ exit
# Exit the root user
exit

Configure the Server#

Create a new directory in the home directory2 to serve as the server's root directory.

~$ cd
# Go back to the home directory
~$ mkdir server
~$ cd ./server
# Enter the new directory

You can choose to configure it on your personal PC and then upload it to the server to run, or you can choose to configure it on the server. This article does not go into detail.

Run the Server#

Create a new file in the server's root directory and rename it3 as start.sh to serve as the startup script.

~$ > start.sh

Here, we use the JVM parameters provided by Aikar.co.

~$ nano start.sh
# After opening the file with nano, enter the JVM parameters
# java -Xms6G -Xmx6G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar paperclip.jar nogui
# Modify the -Xms and -Xmx parameters as needed

Press Ctrl + O and Enter to save, and press Ctrl + X to exit nano4.

Run the script

~$ screen -S server
~$ bash ./start.sh
[Server thread/INFO]: Time elapsed: 4624 ms
[Server thread/INFO]: Done (5.381s)! For help, type "help"

At this point, the Minecraft server is successfully running. After disconnecting the SSH connection, enter

~$ screen -r server

to return to the server terminal5.

Article References and Footnotes#

fabric

Aikar: Adjusting JVM - Very Effective Server Startup Parameters6

Footnotes#

  1. Choose the correct Java version based on the Minecraft version.

  2. The directory you return to with the cd command, you can also choose other directories based on the actual situation.

  3. Pay attention to modifying the file extension as well.

  4. If your personal computer system is macOS, please use the key mapping of the SSH tool instead of Ctrl.

  5. The command does not include ~$.

  6. This link is a reposted link. The original page is in English and is not easy to read. The reposting and translation are not done by me and have nothing to do with me.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.