Update system
yum update -y
Install Java and wget
yum install -y java wget
Allow Minecraft port through the firewall
Insert the following line in your iptables config file, found in “/etc/sysconfig/iptables”
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25565 -j ACCEPT
Example:
vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25565 -j ACCEPT <--- Added Rule
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
~
~
:wq
"/etc/sysconfig/iptables" 14L, 544C written
[root@localhost ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@localhost ~]#
Setup your network.
you will need to edit the network config file in “/etc/sysconfig/network-scripts/ifcfg-eth0”
DHCP
If your using DHCP then just change “ONBOOT=no” to “ONBOOT=yes”
Static
If you need a static address, then change “ONBOOT=no” to “ONBOOT=yes” and change “BOOTPROTO=dhcp” to “BOOTPROTO=static”
add the following to “/etc/sysconfig/network-scripts/ifcfg-eth0”
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BROADCAST=192.168.1.255
DNS1=1.1.1.1
Start Minecraft server on system boot
Create user
useradd -m steve
Create password for steve
passwd steve
Login as your new user.
su steve
Go to user root directory
cd ~/
Download the minecraft server jar
wget https://s3.amazonaws.com/Minecraft.Download/versions/1.8.7/minecraft_server.1.8.7.jar
Create a directory for the start up script and create start up script.
mkdir /home/steve/mc
touch /home/steve/mc/mcstart.sh
Copy and paste the following text into mcstart.sh
#! /bin/sh
# /etc/init.d/mcserver
### BEGIN INIT INFO
# Minecraft CraftBukkit Start script
### END INIT INFO
case "$1" in
start)
echo "Starting mcserver"
MCDIR="/home/steve/"
cd "$MCDIR"
java -Xmx512M -jar minecraft_server.1.8.7.jar -o true &
;;
stop)
echo "Stopping mcserver"
kill `pgrep mcserver`
;;
*)
echo "Usage: /etc/init.d/mcserver {start|stop}"
exit 1
;;
esac
exit 0
Make the script executable
chmod +x /home/steve/mc/mcstart.sh
Add mcstart.sh to the crontab
Access the crontab by running the following command
crontab -e
Add the following to the crontab.
@reboot /home/steve/mc/mcstart.sh start
Start the server.
/home/steve/mc/mcstart.sh start
Note: Starting the server will fail because you need to agree to the end user license agreement.
Agree to the eula
sed -i s/false/true/g eula.txt
Reboot the server and connect to your new Minecraft server.