Introduction: 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 systems have a low occupancy rate and do not require server restarts for upgrades and maintenance, making them very convenient. New server owners may be discouraged by the Linux command line interface (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
A ~$ will be added before the Bash command to indicate that this line is a Bash command. If it is not added, it is a command line output. Adding # indicates that this line is a comment on the previous line.
Environment Installation#
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 viewed in the terminal at any time
~$ screen -S lnmp
~$ su
# Use the root user. If you haven't set a root user password, use the sudo passwd root command to set it
# Do not always operate as the root user, as it poses 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#
Aikar: Adjusting JVM - Very Effective Server Startup Parameters6
Footnotes#
-
Choose the correct version of Java based on the Minecraft version. ↩
-
The directory you return to with the cd command, you can also choose other directories based on the actual situation. ↩
-
Pay attention to modifying the file extension as well. ↩
-
If your personal computer system is macOS, please use the SSH tool's mapped keys instead of Ctrl. ↩
-
The command does not include ~$. ↩
-
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. ↩