{"id":488,"date":"2013-02-23T22:20:02","date_gmt":"2013-02-23T22:20:02","guid":{"rendered":"http:\/\/www.scaine.net\/site\/?p=488"},"modified":"2017-02-25T13:58:23","modified_gmt":"2017-02-25T13:58:23","slug":"step-by-step-install-a-minecraft-server-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.scaine.net\/site\/2013\/02\/step-by-step-install-a-minecraft-server-on-ubuntu\/","title":{"rendered":"Step by Step : Install a Minecraft Server on Ubuntu"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-thumbnail wp-image-498\" src=\"https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/minecraft-280x280.png\" alt=\"minecraft\" width=\"280\" height=\"280\" srcset=\"https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/minecraft-280x280.png 280w, https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/minecraft-480x480.png 480w, https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/minecraft-200x200.png 200w, https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/minecraft.png 512w\" sizes=\"auto, (max-width: 280px) 100vw, 280px\" \/>There are a few guides out there on the internet, but since I run a few Minecraft servers myself, I thought I&#8217;d catalogue the process here for prosperity. This guide will deal with installing Minecraft on Ubuntu 12.04, hardening the install a little, then opening up the necessary ports for making your server available on the internet. Finally, a little tweaking of the Minecraft parameters to ensure that your server isn&#8217;t &#8220;griefed&#8221; by passers-by. It&#8217;s pretty much step by step, so hopefully I won&#8217;t be making too many wild assumptions about your ability. On the other hand, if you have any doubts about what&#8217;s written here, you probably shouldn&#8217;t be putting a Minecraft server publicly on the internet&#8230; just saying. So, what do we need?<\/p>\n<p><!--more--><\/p>\n<h2>Prerequisites<\/h2>\n<p>To start with, you&#8217;ll need an Ubuntu installation. For my server, I use Ubuntu 12.04 LTS desktop edition. Sure, there&#8217;s a server edition, but I like the convenience of dealing with the desktop. And yeah, you can use the server edition and add a desktop &#8211; if that works for you, great. I&#8217;ve experienced a few little foibles around that in the past and given that my hardware is halfway-decent, I&#8217;ll take the performance hit of running the full desktop. So, bottom line, this guide will assume that your server has a desktop.<\/p>\n<h2>Set up a Games Directory<\/h2>\n<p>The bulk of your files for running the server will live in here. My installation uses ~\/Apps\/Games\/Minecraft. Choose a directory path that works for you.<\/p>\n<h2>Download Minecraft<\/h2>\n<p>Fire onto your server and browse on over to <a href=\"https:\/\/minecraft.net\/download\" target=\"_blank\">Minecraft.net download section<\/a> and download the linux server edition (at the time of writing, it&#8217;s the bottom link &#8211; it&#8217;s the jar file, NOT the exe file). What you&#8217;re downloading is just a &#8220;jar&#8221; file &#8211; pretty useless at this point. We&#8217;ll deal with that file later. For the moment, stick that file into the root of your Games Directory.<\/p>\n<p>Note that this is the stock minecraft server, so you won&#8217;t be able to use any of the thousands of add-ons available on the internet. If you want to use those, you&#8217;ll need to download the CraftBukkit edition of the server jar file, which is usually located here :&nbsp;<a href=\"http:\/\/dl.bukkit.org\/\">http:\/\/dl.bukkit.org<\/a>. I&#8217;m hopefully going to write a later article on CraftBukkit, but for the moment, this guide will work with either version.<\/p>\n<h2>Install Java<\/h2>\n<p>The server will need Java installed. I&#8217;ve heard reports that the default Java instance in the Ubuntu repositories will work, but I prefer to use the &#8220;official&#8221; version. Installation these days is a breeze, via <a href=\"http:\/\/www.webupd8.org\/\" target=\"_blank\">WebUpd8&#8217;s PPA<\/a>. Enter the following commands in a terminal on your server :<\/p>\n<pre><code>sudo add-apt-repository ppa:webupd8team\/java\r\nsudo apt-get update\r\nsudo apt-get install oracle-java7-installer<\/code><\/pre>\n<p>Done.<\/p>\n<h2>Start It Up<\/h2>\n<p>We need to start the server briefly to get the defaults created for us. Do that now :<\/p>\n<pre><code>cd ~\/Apps\/Games\/Minecraft\r\njava -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui\r\n<\/code><\/pre>\n<p>And after it&#8217;s calmed down (a minute or so, maximum), type &#8220;stop&#8221; at the console to stop it again. We just needed it to create the files which we&#8217;re now going to edit.<\/p>\n<h2>Edit The Files<\/h2>\n<p>There are two files we&#8217;re going to edit. The most important is <strong>server.properties<\/strong><\/p>\n<p>Here&#8217;s mine, with all the entries I changed in bold.<\/p>\n<pre><code>generator-settings=\r\nallow-nether=true\r\n<strong>level-name=MyServer<\/strong>\r\nenable-query=false\r\nallow-flight=false\r\n<strong>server-port=25565<\/strong>\r\nlevel-type=DEFAULT\r\nenable-rcon=false\r\n<strong>level-seed=-7385098387213481225<\/strong>\r\nserver-ip=\r\nmax-build-height=256\r\nspawn-npcs=true\r\n<strong>white-list=true<\/strong>\r\nspawn-animals=true\r\nsnooper-enabled=true\r\nhardcore=false\r\ntexture-pack=\r\nonline-mode=true\r\npvp=true\r\ndifficulty=1\r\ngamemode=0\r\n<strong>max-players=10<\/strong>\r\nspawn-monsters=true\r\ngenerate-structures=true\r\n<strong>view-distance=12<\/strong>\r\nspawn-protection=16\r\n<strong>motd=Short Message Here<\/strong><\/code><\/pre>\n<p>The full description of all this stuff is on the <a href=\"http:\/\/www.minecraftwiki.net\/wiki\/Server.properties\" target=\"_blank\">Minecraft WIKI here<\/a>. But in short, the level name is the name of the directories that Minecraft will create to store your world. I&#8217;ll cover the port further down this post &#8211; it&#8217;s super important. The seed is customisable and you can type pretty much whatever you want in there &#8211; I got <a href=\"http:\/\/www.minecraftforum.net\/topic\/1542892-seeds-to-spawn-next-to-a-village\/\" target=\"_blank\">that one from the internet<\/a> because it has a village nearby. The whitelist entry will restrict who can connect to your server. More on that later too. I reduce the max-players (from 20) because I only have a handful of people using my server. View distance default is 10, but I like bumping it up a bit (max 15) so that I can see greater distances. This will affect server performance though, so change with care. Finally, motd is the message that appears under your server name in the browser list.<\/p>\n<p>The second file you need to change is the whitelist.txt. Earlier, we changed the white-list option to&nbsp;<strong>true<\/strong> so that we can restrict who can join our server. Now we need to create that list. Just fill it with the Minecraft user names of anyone you want to allow to play, one per line.<\/p>\n<p>What&#8217;s next? Well, if this is going on the internet you should&#8230;<\/p>\n<h2>Choose Your Port<\/h2>\n<p>The default server port for a Minecraft server is 25565. It&#8217;s the server-port entry in the server.properties file we edited earlier. If you&#8217;re only running one Minecraft server then there&#8217;s probably no reason to change this and you&#8217;re good to go. If you&#8217;re going to run more than one, or you want to use a non-standard port (for some reason), you&#8217;ll have to bear that in mind in the next section.<\/p>\n<h2>Harden The Server<\/h2>\n<p>Stop! This is easier than it sounds, but you need to understand a <em>little<\/em> about your network, or you&#8217;ll end up cutting yourself off from your server. That&#8217;s fine if you&#8217;re like me and you have a desktop that you can just undo your change locally, but it&#8217;s a <em>little<\/em> more serious if you have a headless server and you&#8217;re using SSH to access your server.<\/p>\n<p>So find out what network you&#8217;re on. You&#8217;re running a Minecraft server, so you should probably know this stuff, right? So, no, I&#8217;m not going to get into a detailed explanation of TCP\/IP sub-netting. Hopefully, even if this is a mystery to you, the following example is enough for you to make the leap. However, if you&#8217;re in any doubt, seriously reconsider putting your server on the internet.<\/p>\n<p>The two files we&#8217;ll be editing are \/etc\/hosts.allow and \/etc\/hosts.deny. Here&#8217;s mine :<\/p>\n<p><em>Hosts.allow<\/em><\/p>\n<pre><code>ALL: 192.168.1.\r\n25565: ALL<\/code><\/pre>\n<p><em>Hosts.deny<\/em><\/p>\n<pre><code>ALL: ALL\r\n<\/code><\/pre>\n<p>Now I&#8217;m on a 192.168.1.x network here at home. You might be on a 192.168.0 network. Or something else entirely &#8211; so edit those values appropriately! Get this wrong and you&#8217;ve cut yourself off from your server, which will now refuse all incoming connections that aren&#8217;t from 192.168.1.x. Well, your Minecraft server port will work (because of the 25565:ALL line), but that&#8217;s about all.<\/p>\n<p>You can add multiple networks if you need to, just put them in a new line using the example above.<\/p>\n<p>So at this point, I&#8217;d advise a good, old fashioned&#8230;<\/p>\n<h2>Test<\/h2>\n<p>Fire up your server again and make sure that you can connect okay. Same command as before :<\/p>\n<pre><code>java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui<\/code><\/pre>\n<p>Everything okay? Time to put this on the internet then!<\/p>\n<h2>Port Forwarding<\/h2>\n<p>Here&#8217;s what many consider the hardest part of all this. They consider it hard perhaps because every single router out there seems to have a different name for what is actually a fairly simple operation. Basically, we&#8217;re going to ask our router to &#8220;port forward&#8221;. So someone on the internet connects to your public IP address on port 25565 and you have to tell your router that whenever it sees that port coming in, it has to forward the traffic on to your server.<\/p>\n<p>I won&#8217;t lie, I can&#8217;t help with this one. There&#8217;s too many routers out there. Here&#8217;s what it looks like on a Netgear WDR3400 router. I browse to 192.168.1.1 (because I&#8217;m on a 192.168.1\/24 network, remember? So if you&#8217;re 192.168.0\/24, you&#8217;ll need to browse to 192.168.0.1), log into the web interface, scroll down to <strong>Port Forwarding \/ Port Triggering<\/strong>, then create a custom entry. Mine looks like this, because Minecraft runs on port 25565, using TCP (not UDP) and my server&#8217;s address is 192.168.1.100.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-494\" src=\"https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/Selection_028-480x156.jpeg\" alt=\"Port Forwarding\" width=\"480\" height=\"156\"><\/p>\n<p>Done that? Test it again, but this time test it by asking a friend, from their house, to enter your server details into the Minecraft <strong>multiplayer<\/strong> option. What details? Well, if your server isn&#8217;t registered on a dynamic DNS service (and it&#8217;s sad to hear that <a href=\"http:\/\/www.dyncommunity.com\/questions\/21580\/from-dyn-what-happened-to-free-accounts.html\" target=\"_blank\">DynDNS.org have stopped offering free accounts<\/a>!), you&#8217;ll just have to pop on over to a website like <a href=\"http:\/\/whatismyip.org\/\" target=\"_blank\">whatismyip.org<\/a> and tell your helpful friend to use the IP address instead (and of course update them any time that changes because of your ISP&#8217;s policies). So if your public IP was 12.13.14.15, AND you&#8217;d chosen a custom port for your Minecraft server, like 25570, then your helpful testing friend would put <strong>12.13.14.15:25570<\/strong> as the address, like so:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-495\" src=\"https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/Minecraft_029-480x285.jpeg\" alt=\"Minecraft Connection Details\" width=\"480\" height=\"285\" srcset=\"https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/Minecraft_029-480x285.jpeg 480w, https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/Minecraft_029-768x457.jpeg 768w, https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/Minecraft_029-640x381.jpeg 640w, https:\/\/www.scaine.net\/site\/wp-content\/uploads\/2013\/02\/Minecraft_029.jpeg 856w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/p>\n<p>And that should be that.<\/p>\n<p>I&#8217;ll try to follow this post up with an additional post on<\/p>\n<ul>\n<li>How to add the awesome DynMap plugin by changing your server to use the Bukkit jar instead of the official Minecraft jar<\/li>\n<li><a href=\"https:\/\/www.scaine.net\/site\/2013\/02\/step-by-step-install-a-minecraft-server-on-ubuntu\/\">How do perform automated hourly and daily backups of your server<\/a>.<\/li>\n<\/ul>\n<p>Until then, happy Mining!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are a few guides out there on the internet, but since I run a few Minecraft servers myself, I thought I&#8217;d catalogue the process here for prosperity. This guide will deal with installing Minecraft on Ubuntu 12.04, hardening the install a little, then opening up the necessary ports for making your server available on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,8,3,4],"tags":[92,93,91,148,94,90],"class_list":["post-488","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-games","category-software","category-technical","category-ubuntu","tag-bukkit","tag-dynmap","tag-java","tag-minecraft","tag-port-forwarding","tag-server"],"mb":[],"mfb_rest_fields":["title"],"_links":{"self":[{"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/posts\/488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/comments?post=488"}],"version-history":[{"count":22,"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/posts\/488\/revisions"}],"predecessor-version":[{"id":819,"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/posts\/488\/revisions\/819"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/media\/807"}],"wp:attachment":[{"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/media?parent=488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/categories?post=488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scaine.net\/site\/wp-json\/wp\/v2\/tags?post=488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}