Jump to content

  •  

  • iBotModz CBox


    Photo

    [Tutorial] Minecraft Servers: The Dreaded Install! [2/4]


    This topic has been archived. This means that you cannot reply to this topic.
    No replies to this topic

    #1 Quinn

    Quinn

      Colonel Grade 3

    • Global Mods

    • 2,323 posts
    • Joined: 29-August 07

    Posted 17 June 2011 - 04:48 PM

    If you read my last tutorial, about selecting a host, then you probably noticed how much I stressed the difficulty of getting a Minecraft server up and running. Well, its not hugely bad, but you need to know what you're doing. This tutorial is for VPS' and Dedicated servers RUNNING ON LINUX!!!.
    WARNING!: This tutorial assumes that you have root access, and have Java installed and accessible on your server! You will need to be superuser/root for most of this tutorial, if something doesn't work right, you may not have proper privileges!

    1. Lets start with the required programs:

    Windows:
    Putty

    Filezilla


    Linux:
    Putty (Softpedia)

    Filezilla (Pick the one appropriate for your system)


    Mac:
    Just use Terminal (no pictures, sorry)
    Filezilla (Intel Mac) Filezilla (PPC Mac)


    2. Okay, so now, your going to need your login details for the server you're with. You should already have these.

    3. Next, download the minecraft server software from Mojang's website.
    Posted Image


    4. Create a Minecraft directory on your server, and place the .jar you just downloaded in it.
    Posted Image



    5. Now that we've done this, we need to figure out how we are going to launch our server. (LONG AND CONFUSING PART!!!)
    It is fairly simple to launch a minecraft server, as shown below.
    First, cd to your directory. (In my case /***/***/Minecraft)
    Posted Image


    5.1: Launching Time
    Then, your going to want to execute the .jar. They way that the minecraft wiki says to do this is
    java -Xms1024M -Xmx1024M -jar minecraft_server.jar nogui

    However, I find this to be a very generic script, so lets break it into pieces. The "java" tells the system to run it via java. The next parts are "flags", if you will:


    -Xms - Starting heap size
    -Xmx - Maximum heap size
    -jar - Tells java that it's executing a jar.
    The most important part of that is the -Xms and -Xmx. They basically tell java how much memory it is allowed to use. For some systems, 1024M (1 gigabyte) may be fine, but many times it will have to be adjusted according to usage limitations. Please ask your host if you are unsure. On to the next piece, the "minecraft_server.jar". This should stay the same, unless you renamed the file. Finally, "nogui" is there so that the program doesn't try to run with a graphical interface (like it would in windows). However, there are flaws with this script, as detailed below.


    5.2: Screen
    If we just use the above script to launch it, we have to keep putty running in order to keep the server running. This is where screen comes in handy. What screen allows you to do is exit out of putty, without shutting down the server.
    If screen is installed on your server (which I hope it is), then this is for you. Otherwise, carry on.
    Creating a new screen for minecraft may seem confusing, but it really isn't. Personally, I use a script, which I will describe in 5.3, however, this is not necessary. The easiest way to start a minecraft server with screen would be to have it auto detach. I've included an example script below.
    screen -dmS minecraft java -Xms1024M -Xmx1024M -jar minecraft_server.jar nogui

    You should modify this script to your personal needs.
    If you use this script, it may seem like nothing happened. That's what we want. In putty, type in
    screen -r
    , you should now see a bunch of text about worlds being generated (if its the first run), or just regular start-up stuff. Now, don't exit out of putty yet! With putty open, press "Control+A+D" (At the same time.) This should detach the screen, and make it safe for you to close putty.

    (No Screenshots, cause its hard to screenshot keystrokes :p)

    5.3: Automating it!
    If you think typing a script in every time would be a pain in the ass, you'd be absolutely right! That's why we make script files, that we can run (and do the work for us). Making a script is easy, all you need is a text editor (notepad will even work.)
    Here is the script I use to launch my server (bukkit):
    Posted Image


    As you can see, there isn't much to it. The first three lines can be re-used for your script.
    5.3.2: Making your own
    To make your own script, open up notepad (or your text editor of choice), and paste in the following:
    #! /bin/sh 
    BINDIR="$(dirname "$(readlink -fn "$0")")"
    cd "$BINDIR"

    You now have your first three lines. What comes next is up to you. For the final line, you paste the script you made in the above section. Next save it like shown in this picture:
    Posted Image


    5.3.4: Placing and running your script
    Place the script you just saved in the same directory that your minecraft_server.jar is.
    Posted Image


    Now, you need to be able to run it!
    Open up putty, login and cd to your minecraft folder.
    Next, type the following into putty:
    sh xxx.sh

    This should run your script!
    Posted Image

    Sorry for having to grey a lot of stuff out, but unfortunately I have to for security reasons.

    Anyways, that concludes this part of the tutorial! It was long, and probably confusing, but hopefully of use to someone. Please feel free to ask questions!