How to setup a Minecraft Server on CentOS 7 & 8
Do you want to host your own Minecraft Server? In this short tutorial you will learn everything you need to know about setting up and running a lag free server!
Let’s get started! First make connect to your server through a SSH client and an FTP client. If you need help with that we have provided an in-depth tutorial on how to connect found here
Once you are connected we are going to install the following required software:
Update CentOS
sudo yum updateOnce that’s done install: wget, nano, screen by running these
sudo yum install wget
sudo yum install nano
sudo yum install screenNext we will install MySQL to host all your databases on! MySQL databases are so much faster than flat-file. Whenever a plugin has an option to use a database always use it!
sudo wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo chmod +x mariadb_repo_setup
sudo ./mariadb_repo_setup
sudo yum update
sudo yum install MariaDB-server MariaDB-client
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo systemctl status mariadbNow that MariaDB (a fork of MySQL) you can now run the startup script to assign a password to the root password!
sudo mysql_secure_installationRead through the following options that show up and assign a password to the root user!
Now we are going to setup a user for Minecraft. This is always recommended to prevent security backdoors! To create a user follow the next steps show bellow. Please NOTE: Replace “yourusername” with something that works for you!
sudo adduser yourusername
sudo passwd yourusername
# NOW SET THE PASSWORD FOR THAT USER #
sudo usermod -aG wheel yourusername
# This allows the user to have permissions #Port, we are going to make sure port 25565 is open. Or any other port that you want!
sudo firewall-cmd --zone=public --permanent --add-port=25565/tcp
sudo firewall-cmd --reloadOur final step is to install Java, We recommend installing the latest Java openJDK LTS, at the time of writing this article, Java 11 is the latest LTS recommended version. To install it follow this step:
sudo yum install java-11-openjdk-devel
java -version
# Make sure it says the right version and now you are all set #Now we are all set with the requirements on the server side!
Lets make the directory for the new server location to do so follow these steps
sudo su - yourusername
# Replace yourusername with the one we created earlier for Minecraft!
mkdir minecraft
cd minecraftNow that we created a Minecraft directory and we are in it we are going to use our FTP client (FileZilla or your favorite FTP client) and go to the directory: /home/yourusername/minecraft/
In there we will upload our Minecraft Server JAR. We recommend using Spigot or PaperMC that can be found here:
Upload the JAR to the Minecraft directory and we recommend naming it to something user friendly like: server.jar
Once the jar is uploaded lets get back to the SSH client and run the following command.
cd /home/yourusername/minecraft/
# Once again please make sure to replace yourusername with the one we created for Minecraft all the way at the start of this tutorial! #
ls
# That will list all files in that directory. If you have followed everything this far you will see the filename: server.jar show up! #Now we are going to setup a start up scripting and use “screen” to keep the server running even when you close your SSH client! We are going to recommend the following start up script but feel free to use your own if you want!
nano start.sh
# That will open the nano file editor #
# Change the first line where it says -Xms10G -Xmx10G to the amount of ram that your host has provided! Like so: -Xms6G -Xmx6G
NOTE: Please remember not to use ALL of the ram provided on the server, you need to leave 500M - 1GB of ram for the machine to ensure a lag free experience. #
# Copy and paste the code bellow this line #
java -Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar noguiTo exit and save please hit: CTRL + X you will be asked to save, press Y then hit enter and enter again!
We are all set! We installed the required software, we setup a new user for security, and we uploaded our server jar with the correct script!
Our final step is to accept EULA and to start the server and connect to it!
We are going to use screen in the next few commands, If you have more questions about screen click here to learn even more about it. We are going to go over few of the commands of screen but not all of them.
screen -S mainserver
# Now you will run the start.sh script #
sh start.sh
# The script will run for a bit but it will say that there was an ERROR that EULA.txt has not been accepted. To fix this follow the steps #
nano eula.txt
# in there you will see that it says : false change that to : true and save the file CTRL + X hit Y then hit enter and enter again! #
sh start.sh
# The server is now running! #You are all set! Now don’t forget to detach from the screen, like so:
CTRL + A + D
To re-attach to the screen and see the server console follow these steps:
screen -r mainserverCongratulations! You did it! If you have any questions feel free to reach out to us and we can set this up for you for FREE!

