[Tutorial] How to run a Minecraft network on your Linux Dedicated Server

Discussion in 'Systems Administration' started by MasterDoctor, Aug 31, 2016.

  1. Hey everyone! This is my first guide so be sure to let me know what you think of it.
    In this guide, I will cover Debian/Ubuntu. Just ask me if you want to cover another distro.

    Anyway, without any more rambling... here's the tutorial:

    Step 1: Logging in!
    Now, of course, we can't just connect to the dedicated server using remote desktop or TeamViewer or something. To interact with the server, we use good, old SSH. If you're on a Mac, you have a tool built-in for connecting to an SSH server but if you're using Windows, you'll have to download an SSH program.
    I'd recommend PuTTY, you can download it from here. If you're on a Linux machine, I don't know why you're reading this tutorial.
    The rest of this step depends on the Operating System that you're using, so just have a look at the spoiler for the system-related instructions.
    1) Download and Install an SSH client. If you use one other than PuTTY, I'll assume that you either know/have instructions on how to use that client so you can skip ahead to step 3.
    2) Open PuTTY and enter the IP of your dedicated server inside the "Host Name (or IP address)" box and just leave the port as 22 unless you were provided with an alternative port. Once you've done this, click the button at the bottom of the window called "Open" and a shell window should appear.

    [​IMG]

    3) At the username and password prompt, enter 'root' for the username and then enter the password for the root user that you either entered or supplied with when the server was setup. If you do not have the root password, you may have to contact your host's support.
    Note: The password characters will not show as you type them, on the whole, you are in fact typing something - even if it doesn't look like it.
    Code (Bash):
    login as: root
    root@myip's password:
    4) If you get a prompt, congratulations! You are now logged in!
    1) Open Terminal and type in the following command, substituting "myip" with the IP address of your server and "myport" with the SSH port. (If you were not given one, just don't type it)
    Code (Bash):
    ssh root@myip:myport
    2) You should now be at a password prompt. If any messages about keys show, just type in 'yes'. (This is basically asking if you're sure that you are connecting to the server that you think you are)
    3) At the password prompt, enter the password for the root user that you either entered or supplied with when the server was setup. If you do not have the root password, you may have to contact your host's support.
    4) If you get a prompt, congratulations! You are now logged in!

    Step 2: Installing the JRE
    Obviously, Minecraft being a game that runs on Java, you're going to have to install a JRE.
    After a bit of nagging from the community (psst @Headhunterz_ ), I've updated this step to cover Oracle's JVM instead of OpenJDK. To make this easier, I'm going to use the WebUpd8 PPA repository as suggested by Salem on the AskUbuntu community.
    All you have to do is run the following commands:
    Code (Bash):
    sudo apt-add-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer
    That, in order:
    • Adds the WebUpd8 repository to aptitude,
    • Updates the aptitude package list,
    • Installs Oracle Java 8
    Now, you'll want to make sure Java is in your PATH variable. You can do this with the following command:
    Code (Bash):
    export JAVA_HOME=/usr/lib/jvm/java-8-oracle
    If that doesn't work for you, you can try doing this the manual way, as Salem posted on his answer.
    http://askubuntu.com/a/521154

    Oh, and quick update, @Headhunterz_ has just pointed something out... You will also need to set the default JRE. Which you can do with this command:
    Code (Bash):
    apt install oracle-java8-set-default --yes
    Thanks, @Headhunterz_

    Step 3: Creating the directory structure
    Now, we've got to store the server files somewhere. I decided to store mine in
    Code (Text):
    /home/server/games/minecraft/{server-name}
    but you can pretty much store them wherever. Although do take note that later, we will create a separate account to run the servers under, so make sure it's not too stupid.
    Also, don't worry about long file paths because we'll be writing a script to start the servers.
    So, once you've chosen your file structure, navigate to the root of the first server folder. For me, this will be called hub, so following my directory structure, I'll want to run this command (this is assuming you've made all the required directories):
    Code (Bash):
    cd /home/server/games/minecraft/
    Code (Bash):
    mkdir hub; cd hub
    Step 4: Install Spigot
    If you're like me, you'll want a quick one liner to install Spigot. So this command will download the latest copy of Spigot from Yive's Mirror:
    Code (Bash):
    wget http://tcpr.ca/files/spigot/spigot-latest.jar
    After a bunch of posts during which people just insulted and verbally abused each other, I finally decided to update this part of the tutorial.
    So, if you just want a server up and running quickly, you can use the method I've described.
    If you want to do things the "proper" way, you can use BuildTools. There's a tutorial on using BuildTools that can be found here:
    https://www.spigotmc.org/wiki/buildtools/
    That's all you had to do!

    Step 5: Setup an account for the server
    Note: If you followed my directory structure, chances are you didn't create the account before you created the directory structure. So you'll need to run this command too:
    Code (Bash):
    chmod -R 774 /home/server/
    This is all you need to add the user:
    Code (Bash):
    adduser server
    If you aren't prompted to enter a password for the account, simply do
    Code (Bash):
    passwd server
    If you created the directory structure before you created the user, you can also do
    Code (Text):
    chown -R server /home/server
    to give the server account ownership of the directory and all the files/folders inside it. (-R means recursive.)

    Step 6: Start the server
    For managing the servers, I'm going to use a program called mark2 written in Python (as @Koboldthegreat is happy to point out.)
    You can check the program out here.
    This program basically just provides you with a fancy UI for managing your servers plus holding a lot of other features.
    So, to get started with mark2, you'll need to install it's dependencies, which can be done with the following command (as shown by gsand on the mark2 installation page):
    Code (Bash):
    sudo apt-get install git libssl-dev python-dev python-feedparser python-psutil python-twisted-core python-twisted-mail python-twisted-web python-twisted-words python-urwid
    Next, you can just follow these instructions:
    https://github.com/gsand/mark2/blob/master/INSTALL.md#installation-1

    Creating a starter script
    Coming soon!

    How to use mark2 - (the basics):
    Coming soon!
     
    #1 MasterDoctor, Aug 31, 2016
    Last edited: Sep 17, 2016
    • Funny Funny x 4
    • Useful Useful x 3
    • Like Like x 1
    • Agree Agree x 1
  2. Very good tutorial
     
    • Friendly Friendly x 1
  3. latiku

    latiku Previously Foxvific
    Supporter

    All you did was copy/paste from the wiki.
     
    • Agree Agree x 4
  4. What post on the wiki?
     
  5. Thanks!
     
  6. Openjdk is to be considered as bad choice
     
  7. mark2 is relatively outdated and unmaintained.
     
    • Funny Funny x 1
  8. Yes, but it's still a great tool and I've been using it without any issues.
    Although, I suppose, I could write about using 'screen' to manage servers?
     
  9. I understand that, but why?
    I haven't had any noticeable performance or stability increases in using Oracle's JVM over OpenJDK
     
  10. OpenJDK doesn't have some features or classes whilst the oracle version it has
     
  11. Oh right.
    I'll update the tutorial
     
  12. For ubuntu just use this:
    Code (Text):
    apt update
    apt install software-properties-common
    apt-add-repository ppa:webupd8team/java
    apt update
    apt install oracle-java8-set-default --yes
     
  13. Updated!
     
  14. If anything, tmux.
     
  15. It's so much easier than this (at least for me anyway)...

    1. Login
    2. Install Java 8
    3. Create a directory
    4. Install Spigot to directory
    5. Install Screen
    6. Create Screen and run Spigot
    7. Wait for the $$$ to roll in
     
    • Funny Funny x 3
  16. I'm pretty sure I just described that but in more detail and using mark2 instead of screen :p

    Edit: And sadly, without step 7
     
  17. How does one run two mc servers on one linux box (ubuntu) both on the default port? Two mc. subdomains, two servers, both 25565, one box.
     
  18. latiku

    latiku Previously Foxvific
    Supporter

    I don't understand why you're trying to hide it, you're sad.
     
  19. I actually don't know, could you please show me the link
     
  20. Good Tutorial
     
    • Friendly Friendly x 1