{"id":994,"date":"2015-07-14T21:27:50","date_gmt":"2015-07-14T21:27:50","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=994"},"modified":"2015-07-14T21:50:15","modified_gmt":"2015-07-14T21:50:15","slug":"set-up-minecraft-server-on-centos-6","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/set-up-minecraft-server-on-centos-6\/","title":{"rendered":"Set up Minecraft Server on CentOS 6"},"content":{"rendered":"<p>Update system<\/p>\n<pre>yum update -y<\/pre>\n<p>Install Java and wget<\/p>\n<pre>yum install -y java wget<\/pre>\n<p><strong>Allow Minecraft port through the firewall<\/strong><\/p>\n<p>Insert the following line in your iptables config file, found in &#8220;\/etc\/sysconfig\/iptables&#8221;<\/p>\n<pre>-A INPUT -m state --state NEW -m tcp -p tcp --dport 25565 -j ACCEPT<\/pre>\n<p>Example:<\/p>\n<pre><strong>vi \/etc\/sysconfig\/iptables<\/strong>\r\n# Firewall configuration written by system-config-firewall\r\n # Manual customization of this file is not recommended.\r\n *filter\r\n :INPUT ACCEPT [0:0]\r\n :FORWARD ACCEPT [0:0]\r\n :OUTPUT ACCEPT [0:0]\r\n -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\r\n -A INPUT -p icmp -j ACCEPT\r\n -A INPUT -i lo -j ACCEPT\r\n -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\r\n -A INPUT -m state --state NEW -m tcp -p tcp --dport 25565 -j ACCEPT &lt;--- Added Rule\r\n -A INPUT -j REJECT --reject-with icmp-host-prohibited\r\n -A FORWARD -j REJECT --reject-with icmp-host-prohibited\r\n COMMIT\r\n ~\r\n ~\r\n :wq\r\n\"\/etc\/sysconfig\/iptables\" 14L, 544C written\r\n [root@localhost ~]# <strong>service iptables restart<\/strong>\r\n iptables: Setting chains to policy ACCEPT: filter [ OK ]\r\n iptables: Flushing firewall rules: [ OK ]\r\n iptables: Unloading modules: [ OK ]\r\n iptables: Applying firewall rules: [ OK ]\r\n [root@localhost ~]#<\/pre>\n<p>&nbsp;<\/p>\n<h1><strong>Setup your network.<\/strong><\/h1>\n<p>you will need to edit the network config file in &#8220;\/etc\/sysconfig\/network-scripts\/ifcfg-eth0&#8221;<\/p>\n<p><strong>DHCP<\/strong><\/p>\n<p>If your using DHCP then just change &#8220;ONBOOT=no&#8221; to &#8220;ONBOOT=yes&#8221;<\/p>\n<p><strong>Static<\/strong><\/p>\n<p>If you need a static address, then change &#8220;ONBOOT=no&#8221; to &#8220;ONBOOT=yes&#8221; and change &#8220;BOOTPROTO=dhcp&#8221; to &#8220;BOOTPROTO=static&#8221;<\/p>\n<p>add the following to &#8220;\/etc\/sysconfig\/network-scripts\/ifcfg-eth0&#8221;<\/p>\n<pre>IPADDR=192.168.1.100\r\nNETMASK=255.255.255.0\r\nGATEWAY=192.168.1.1\r\nBROADCAST=192.168.1.255\r\nDNS1=1.1.1.1<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Start Minecraft server on system boot<\/strong><\/p>\n<p>Create user<\/p>\n<pre>useradd -m steve<\/pre>\n<p>Create password for steve<\/p>\n<pre>passwd steve<\/pre>\n<p>Login as your new user.<\/p>\n<pre>su steve<\/pre>\n<p>Go to user root directory<\/p>\n<pre>cd ~\/\r\n<\/pre>\n<p>Download the minecraft server jar<\/p>\n<pre>wget https:\/\/s3.amazonaws.com\/Minecraft.Download\/versions\/1.8.7\/minecraft_server.1.8.7.jar<\/pre>\n<p>Create a directory for the start up script and create start up script.<\/p>\n<pre>mkdir \/home\/steve\/mc\r\ntouch \/home\/steve\/mc\/mcstart.sh<\/pre>\n<p>Copy and paste the following text into mcstart.sh<\/p>\n<pre>#! \/bin\/sh\r\n# \/etc\/init.d\/mcserver\r\n\r\n### BEGIN INIT INFO\r\n# Minecraft CraftBukkit Start script\r\n### END INIT INFO\r\n\r\ncase \"$1\" in\r\n\u00a0 start)\r\n\u00a0\u00a0\u00a0 echo \"Starting mcserver\"\r\n\u00a0\u00a0\u00a0 MCDIR=\"\/home\/steve\/\"\r\n\u00a0\u00a0\u00a0 cd \"$MCDIR\"\r\n\u00a0\u00a0\u00a0 java -Xmx512M -jar minecraft_server.1.8.7.jar -o true &amp;\r\n;;\r\n\u00a0 stop)\r\n\u00a0\u00a0\u00a0 echo \"Stopping mcserver\"\r\n\u00a0\u00a0\u00a0 kill `pgrep mcserver`\r\n\u00a0\u00a0\u00a0 ;;\r\n\u00a0 *)\r\n\u00a0\u00a0\u00a0 echo \"Usage: \/etc\/init.d\/mcserver {start|stop}\"\r\n\u00a0\u00a0\u00a0 exit 1\r\n\u00a0\u00a0\u00a0 ;;\r\nesac\r\nexit 0<\/pre>\n<p>Make the script executable<\/p>\n<pre>chmod +x \/home\/steve\/mc\/mcstart.sh<\/pre>\n<p><strong>Add mcstart.sh to the crontab<\/strong><\/p>\n<p>Access the crontab by running the following command<\/p>\n<pre>crontab -e<\/pre>\n<p>Add the following to the crontab.<\/p>\n<pre>@reboot \/home\/steve\/mc\/mcstart.sh start<\/pre>\n<p>Start the server.<\/p>\n<pre>\/home\/steve\/mc\/mcstart.sh start<\/pre>\n<p>Note: Starting the server will fail because you need to agree to the end user license agreement.<\/p>\n<p>Agree to the eula<\/p>\n<pre>sed -i s\/false\/true\/g eula.txt<\/pre>\n<p>Reboot the server and connect to your new Minecraft server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;\/etc\/sysconfig\/iptables&#8221; -A INPUT -m state &#8211;state NEW -m tcp &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/set-up-minecraft-server-on-centos-6\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,3,118],"tags":[17,281,120],"class_list":["post-994","post","type-post","status-publish","format-standard","hentry","category-centos-linux","category-linux","category-minecraft","tag-centos","tag-minecraft","tag-minecraft-server"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=994"}],"version-history":[{"count":21,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/994\/revisions"}],"predecessor-version":[{"id":1019,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/994\/revisions\/1019"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}