This tutorial will guide you how to setup and run your own minecraft server on a Linux CentOS 6 in no time. Running your own server lets you play together with your friends and family with your own set of rules. Open Firewall / IPTables ports for minecraft We need to ensure minecraft port is opened else you will not be able to connect to the server. sudo iptables -I INPUT 1 -p tcp -m tcp --dport 25565 -j ACCEPT sudo service iptables save sudo service iptables restart Preparing Directory for Minecraft Server First we should create a directory for our minecraft server at /home folder as shown (** You may name the folder to your preferred choice) mkdir /home/minecraftsvr cd /home/minecraftsvr/ Next we need to install Java on CentOS to run the server since minecraft is a Java-based game. sudo yum install java-1.8.0-openjdk
Verify if Java had been successfully installed Download Minecraft Server Jar file Now that we had java installed, we are ready to download our Server file as shown. wget https://s3.amazonaws.com/minecraft.download/versions/1.9/minecraft_ser ver.1.9.jar Next we turn the downloaded jar file into executable file by issuing the following command chmod +x minecraft_server.1.9.jar Installing Screen Utility By default, minecraft server will stop running once the SSH session is closed hence we need this utility to keep the server running in the background after we quit our SSH session upon launching the server. sudo yum install screen
Once we are done installing screen, we are ready to use it and start our Minecraft Server. Starting Minecraft Server for the first time Before we start our Minecraft server we need to run screen which create an instance of the screen. ** Xmx1024M is the amount of ram you will be allocating to the server. If you are running a server with 512M then ensure to change it accordingly. screen echo 'eula=true' > "/home/minecraftsvr/eula.txt" sudo java -Xmx1024M -Xms1024M -jar minecraft_server.1.9.jar nogui You should be seeing something similar as shown.
We can now test logging in with our Latest Minecraft Client. Congratulation! Your Minecraft server is now ready for your family and friends. Start Minecraft Server on server restart / Boot (Optional) Next we might want to setup our Minecraft Server to start automatically during server boot up or restart.
We will now create a Minecraft Server startup script as followed nano /home/minecraftsvr/startminecraft.sh Content of the startup script #!/bin/bash clear echo -e "Starting Minecraft.." sleep 5 cd /home/minecraftsvr/ screen -A -m -d -S minecraftsvr java -Xmx768M -Xms768M -jar /home/minecraftsvr/minecraft_server.1.9.jar nogui Next we will enable execute permission for the script we had just created with the following command chmod +x /home/minecraftsvr/startminecraft.sh Next we like to test if the script is being configured correctly by running the following command. /home/minecraftsvr/startminecraft.sh You should see similar output as shown. The script will launch an instance of screen and start Minecraft Server before detaching itself from the screen. You will be able to manage it by reattaching back to the screen console with screen -r minecraftsvr Finally we will now add the script to /etc/rc.local so it will start our Minecraft Server
during boot up. nano /etc/rc.local Append sh /home/minecraftsvr/startminecraft.sh to the last line of the file Congratulation! Our Server will now start during boot or restart. Screen Utility Cheat Sheet To detach from the current screen, issue keyboard command Ctrl+a + d To list screen issue command: screen ls To re-attach to screen (Needed when you login to your server ssh session and want to manage your minecraft server) issue command: screen -r number_of_minecraft_instance e.g screen -r 1