[Tutorial by an 11 year-old] Online MC 1.12.2 and Spigot server Ubuntu 18.04

Discussion in 'Systems Administration' started by MrCobalt, Jun 5, 2018.

  1. Hello! You want to set up a Minecraft server for you to play with your friends? Or do you just want to play online? Well then here is a tutorial for you! In this tutorial we will be setting up a Minecraft server for free(Free being the cost of the Server PC aside. If you want completely free just look up Minehut. Free. Nearly lag-free.)!

    So let's get started! First to get the MC server started.
    So you will have to SSH to your server from another PC. If you have Linux or mac(as your everyday PC) just open terminal and type
    Code (Text):
    and then enter your pass
    On windows install Putty then ssh to your server.
    Ok! Now to install your server
    Code (Text):
    sudo apt update
    This will update apt's repositories so that no installation errors occur.
    Code (Text):
    sudo apt install default-jdk
    This should install the latest version of Java JDK.
    Now install screen:
    Code (Text):
    sudo apt install screen
    And now to get BuildTools!
    First make a new user to run the MC server without sudo.
    Code (Text):
    useradd newusername
    Code (Text):
    sudo passwd newusername
    Code (Text):
    mkdir /home/newusername/minecraft
    Now to login:
    Code (Text):
    login new username
    Download:
    Code (Text):
    wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
    Now run BuildTools!
    Code (Text):
    java -jar BuildTools.jar --rev 1.12.2
    This will take some time.

    Ok! Now it is time to make a script for the server to start!
    Ok now! As your main user(The one that you didnt create):
    Code (Text):
    sudo chown -R newuser /home/newuser/minecraft
    and:
    Code (Text):
    sudo chmod -R 755 /home/newuser/minecraft
    Ok now back to your newuser
    Code (Text):
    cd /home/newuser/minecraft
    Code (Text):
    nano start.sh
    In the script:
    This part will matter based on how much ram you have
    Code (Text):
    cd /home/newuser/minecraft
    screen -S mc -d -m java -Xms8g -Xmx20g -jar /home/aforsyth/minecraft/spigot-1.12.2.jar nogui
     
    I have a 24 GB system. I left 4 GB out. Depending on what else you have running:
    8GB: Min = 2g Max = 6 or 7g
    12GB: Min = 4g Max = 9 or 10g
    16GB: Min = 6g Max = 12 or 13 or 14g
    24GB: Min = 8g Max = 16 - 20g
    32GB: Min = 12g Max = 28 - 30g
    Feel free to change it up, and if you have any recommendations, let me know.
    To make the script executable:
    Code (Text):
    sudo chown newuser start.sh
    and
    Code (Text):
    sudo chmod 744 start.sh
    Now to run the server
    Code (Text):
    ./start.sh
    Now it should stop the server.
    Code (Text):
    nano eula.txt
    Change eula to true
    then save & exit.
    Now, again:
    Code (Text):
    ./start.sh
    Ok. So the server should be running now. View the console by typing
    Code (Text):
    screen -r mc
    You can stop it from the console by typing "stop"
    Now we need to set up the bind9 domain name system server.
    As main user:
    Code (Text):
    sudo apt install bind9
    Then:
    Code (Text):
    cd /etc/bind
    Now we are in the bind directory.

    Now you need to pick your domain name. To check if a name is taken, use

    Code (Text):
    ping yourdomainnamehere.ext
    and if it cant connect, you can use that name!

    yourdomainnamehere: the name you want your server to have. example:blackmc(that is to be my server)
    ext: the extension(com, int, org)

    Code (Text):
    sudo nano db.yourdomainnamehere.ext
    Now in that file:
    Code (Text):

    $TTL    86400
    @   IN  SOA mc.domainname.ext. username.domainname.ext. (
                 20             ; Serial
                 604800     ; Refresh
                 86400       ; Retry
                 2419200   ; Expire
                 86400 )     ; Negative Cache TTL
    ;
    @   IN  NS  domainname.ext.
    @ IN A 192.168.x.x
    mc IN A 192.168.x.x
     
    then save exit

    NOTE: Change the number in the serial line to a random number larger than before when changing these files: rev.domainname.ext, db.domainname.ext

    Code (Text):
    sudo nano rev.yourdomainnamehere.ext
    Now in that file:
    Code (Text):

    $TTL    86400
    @   IN  SOA mc.domainname.ext. username.domainname.ext. (
                 20             ; Serial
                 604800     ; Refresh
                 86400       ; Retry
                 2419200   ; Expire
                 86400 )     ; Negative Cache TTL
    ;
    @   IN  NS  mc.domainname.ext.
    @   IN  PTR domainname.ext.
    mc IN A 192.168.x.x
    thelastx  IN PTR mc.domainname.ext.
     
    Save and exit.
    Code (Text):
    sudo nano named.conf.local
    In this file:
    Code (Text):

    zone "domainname.ext" IN {
            type master;
            file "/etc/bind/db.domainname.ext";
            allow-update { none; };
     };
    zone "x.168.192.in-addr.arpa" IN {
            type master;
            file "/etc/bind/rev.domainname.ext";
            allow-update { none; };
     };
     
    Now
    Code (Text):
    sudo systemctl bind9 reload
    The last step you need to look up yourself. It's different for everybody.
    You need to look up how to port forward for your router model. But the port you need to port forward is 25565. You also need to use your minecraft server's address ex:192.168.0.218 in your routers dns servers
    When you are done you should be able to play with your friends! :D
     
    #1 MrCobalt, Jun 5, 2018
    Last edited: Aug 15, 2018
    • Like Like x 5
  2. Assuming you're the 11-year-old, well done! This is a great, thorough introduction to the topic.
     
    • Like Like x 1
  3. Thanks! I am actually 11! It's pretty ridiculous. Sort of. I mean, I do spend half my day with my Linux system. Im setting up my server right now! I just have to get my dad to set up my seperate net because my dad is smart and knows not to let me port forward something on his network(I have my own router and his ISP gives him 16 IPV6 Networks only one IPV4 net though :/) i actually just realized a little command i missed. That may be the difference between the server working and not. I for got to make the script executable.
     
  4. Screen? Nonono, tmux is like 10x better, especially if you end up using a Bungee network.
     
  5. @AlanZ
    What is the difference? I've never used tmux. It may just be opinion based. I use screen.
     
  6. Well, taking a look back at screen there are a lot of things I didn't know you could do with it. I still think tmux is better though :p
     
    • Funny Funny x 1
  7. Not sure what version of Debian or Ubuntu this is but I suggest replacing apt-get with apt and service with systemctl and maybe change the title since this is probably aimed at Debian-based distros.
    Excellent tutorial considering it's from an 11 year old, can already see you in the IT world when you're an adult.
     
    • Like Like x 1
  8. Cool. I like screen
     
  9. I really enjoy stuff like this. It's fun. Coding is cool. You can make the computer do everything. In fact this afternoon in created a bash script(3 TBH) that heats up raspi to 80C then keeps it around there. Stay tuned and be ready for my server to come out! It will be at mc.blackmc.int or just blackmc.int. You will need to sign up through the web interface at blackmc.int in the web browser. Then you will be whitelisted.
     
  10. If this is running under Ubuntu desktop and you never use the GUI, you can disable it. I don't know how in 18.04, but I know it's a service called "lightdm" in 16.04.

    Sounds cool. I'll need to look into that.
     
    • Like Like x 1
  11. Might aswell completely remove it instead of disabling it or just install the server edition.

    "You will need to sign up through the web interface at blackmc.int in the web browser. Then you will be whitelisted." Not sure why you'd want this.
     
    • Like Like x 1
  12. I prefer to at least have an accesible terminal at startup. Oh, wait. That's what disabling the GUI is, isn't it. Once, I screwed up a DHCP server on my pi and couldnt connect over ssh. I fixed it though.



    I wanted to show off my PHP skills! :D :p I also have a little viewer for seeing which usernames signed up through the web interface. I'm using the Websend plugin to auto-whitelist. It's pretty neat IMO.
     

  13. ahem nodejs > php

    "I prefer to at least have an accesible terminal at startup."
    You'd definitely want the server edition then.
     
    • Like Like x 1
  14. MiniDigger

    Supporter

    I would change these up a bit, first I would add -A so that the screen adapts to your window size, then I would recommend not to set xmx to 20g. thats way to much. 8gb is just fine. generally you should look at https://mcflags.emc.gs/ to find good java startup flags for minecraft.
    you also can remove to nogui, spigot doesn't use that.
    the command I would recommend looks like this:
    Code (Text):
    screen -AmdS mc java -Xms8G -Xmx8G -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AggressiveOpts -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs -jar /home/aforsyth/minecraft/spigot-1.12.2.jar
     
  15. ahem What if I don't want to learn nodejs right now
    Ok. Im not reinstalling OS though.
     
  16. Hmm. This looks cool. That is a lot of flags. I like 20g becuase I dont really have much else running on there except a webserver and a DNS server.
     
  17. Less is sometimes more, especially when GC should work correct.
     
  18. MiniDigger

    Supporter

    Your server should never use 20gb. If that's the case you have sevre issues elsewhere.
     
  19. If you know Java and want to get into Bukkit plugin development, I'm sure this site is for you. In fact, we need more people who know what they're doing. Just visit the spigot plugin development category and take a look at all the threads started by people who don't know how to read a stack trace.
     
    • Funny Funny x 1
  20. I know how to read a stack trace, I belive. Im not THAT helpless. :p