minecraft-server-guide

How to create free Minecraft server hosted in the cloud and setting up a panel for it

Stars
0
Committers
3

How to set up a free Minecraft server & panel in Oracle Cloud 🆓

This guide covers setting up a free Minecraft server and then using Pterodactyl to create a panel for it. Everything will be hosted in the cloud for free by using Oracle Cloud. All the steps in this guide can be followed for free but be sure to check the Prerequisites.

I will use the Curseforge modpack Craft to Exile 2 as an example in this guide, you can also follow along with any other type of server (such as Vanilla).

Prerequisites

  • A valid credit card: This cannot be a single-use credit card, we will be using this to sign up for Oracle Cloud and using pay-as-you-go to get the free VM as quickly as possible. If you follow the steps in this guide correctly nothing will be deducted from your credit card.
  • A domain: This is necessary for the Pterodactyl panel. You can follow this guide on how to get a free domain (or skip this if you do not care about the panel).

Windows Users

If you are using Linux or Mac you can probably skip this because this is already integrated with your PC. Windows users should install the following programs.

  • Terminal SSH / PuTTY: To access the terminal for the virtual machine and execute commands.
  • WinSCP: To access the files on your virtual machine.

Table of Contents

Creating a free cloud-hosted Minecraft server ☁️

In this section, we set up the Minecraft server using Oracle Cloud. If you prefer watching a video instead of reading, I'd suggest this video which covers everything in this section.

[!Note] Oracle Cloud does not always load properly on Google Chrome, so I suggest using a different browser like Microsoft Edge or Firefox.

Creating an account

  • Start by signing up for Oracle Cloud if you have not yet done it.
  • Set a Home Region as close as possible, I am from The Netherlands so I will select Netherlands Northwest (Amsterdam)
  • Add your Payment / Identity Verification
  • After filling in all the details, you will get the following pop-up. You can only fill in a credit card that is not single-use.
  • $1 will be reserved from your credit card, but you will instantly get it back

Setting up the VM instance

After signing up head to the Oracle Cloud dashboard and scroll down to Create a VM instance.

  • Here you want to fill in a name, for instance Minecraft VM.
  • Leave everything to their default settings, except for the following.
    • Image: This should be set to Ubuntu, you want to use the latest Ubuntu version that is not Minimal. At the time of writing that is Canonical Ubuntu 22.04
    • Shape: You want to set the Shape series to Ampere, this will give you one option for Shape name which should be VM.Standard.A1.Flex. Then for the number of OCPUs set it to 4 and the Amount of memory (GB) should be set to 24.
  • For the final step on this page you want to click on Save private key, this is necessary for later steps where we access the files of the server.
  • Now you can press Create at the bottom left of the page.

If you get an error that the VM is not available, then change your settings to Pay As You Go. You can do this in the Billing settings, under the tab Upgrade and Manage Payment. Just like registering this change will reserve about 100 dollars on your credit card and instantly give it back after confirming the credit card.

Setting up the subnet

After creating the VM you will see the overview of the instance. On the tab Instance information you will see the Subnet under Primary VNIC, click on it. alt text This will bring you to the overview of the subnet information, here you want to click on the only option under Security Lists. alt text Click on Add Ingress Rules and fill in the following:

  • Source CIDR: 0.0.0.0/0
  • IP Protocol: TCP
    Click on + Another Ingress Rule and fill in the following for that:
  • Source CIDR: 0.0.0.0/0
  • IP Protocol: UDP
    This will port forward everything, if you want to be on the safe side you can fill in the Destination Port Range with the port you want to forward.

SSH into the server

This can be done using PuTTY or using the command line if you have SSH set up. If you are unsure if you have SSH set up on your PC, then open a terminal and write ssh. If there is no error then you can use SSH and following the steps of Command line.

If you would like to use the command line method on Windows, then follow these steps.

Command line

Start by locating the private key file that you saved previously. Copy the location of this file for instance, C:\Users\Stephan\Downloads\oracle\private.key. Next, find the IP address of your Oracle VM. Use the following syntax to SSH into it:

ssh -i "{private key location}"ubuntu@{your VM ip address}

For example, I use the following command:

ssh -i "C:\Users\Stephan\Downloads\oracle\private.key"[email protected]

PuTTY

The second method of accessing the terminal of your VM is by using PuTTY.

  • Download and install PuTTY
  • Search for PuTTYgen in your Windows applications and open it
  • Click on Load and search for your private key and open it
    • Be sure to set the file search to All Files (*.*) otherwise you won't be able to find your key.
      alt text
  • After loading the key press on Save private key
    • You can save it without a passphrase
  • Now open PuTTY
  • Use ubuntu@{your ip address} for the hostname
  • Then open the Credentials menu, found under Auth
    alt text
  • Click on Browse... behind the text box for Private key file for authentication
  • Search for the file you just generated with PuTTYgen and click Open
  • Now you can click on Open and it will start the connection
  • You will get a message from PuTTY Security Alert, press Accept
  • Now you are in the terminal of your VM

Updating the software

Now we need to update the software that the VM uses. Use the following commands.

  • Start with getting elevated access:
sudo -s
  • Get the available updates:
apt update
  • Install the upgrades:
apt upgrade

After the upgrade, you will see the following screen. You can press Tab to select <Ok> and then enter to exit it. alt text There might be multiple services that need to be restarted, just leave them on their default settings and select <Ok>.

Firewall settings

apt install firewalld
firewall-cmd --permanent --zone=public --add-port=25565/tcp
firewall-cmd --permanent --zone=public --add-port=25565/udp
firewall-cmd --reload

If you get the following screen after installing Firewalld then restart the VM. alt text You can restart it by simply heading over to the overview of instances and clicking reboot. alt text

DBUS Error

If you get an error Error: DBUS_ERROR: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory then use the following commands.

sudo apt-get install dbus
sudo systemctl start dbus
sudo systemctl enable dbus
sudo systemctl status dbus
sudo systemctl restart firewalld
sudo firewall-cmd --state

Then try the same commands for Firewalld again.

Screen

The following commands are handy to know if you plan on not using the Pterodactyl panel or any other panel. These commands are for Screen, which you can use to run something in the background such as your server. If you are following this guide and plan to use the panel then you can skip this section.

To list all attached and detached screen

screen -ls

To stop a screen session

screen -XS <session-id> quit

To run the server in a screen session (be sure to be in the same directory as the run.sh file)

screen ./run.sh

To exit a screen session: CTRL A + D

To reattach to a session

screen -r <session-id>

Accessing the server files

If you do not plan to use the Pterodactyl panel, then follow this section. Otherwise, you can skip it since it will be covered in the following section.

  • SSH into the VM like you did before and execute this command:
sudo chown -R ubuntu:ubuntu .

Pterodactyl Panel 🦖

This section covers the process of how to set up the Pterodactyl panel, which is very useful for managing your server. If you prefer watching a video over reading, then I suggest watching this video which covers almost everything in this section.

Creating the panel VM

  • Head back to the Oracle Cloud dashboard and scroll down to Create a VM instance.
  • You can name this VM panel or any other name that reminds you that this is not the Minecraft server VM
  • Select as image Ubuntu 22.04, just like previously
  • Click on Specialty and previous generation
  • Select VM.Standard.E2.1.Micro (or any other with Always Free-eligible)
  • Click on Select shape
    alt text
  • Save the private SSH keys

Add panel and server to website records

Head to the website where you bought your domain.

  • Go to the settings for DNS
  • Add two new A Records
    • One with the IP of your Minecraft server
    • The other with the IP of the Pterodactyl panel
  • Make sure both have a different host name, for instance minecraft and panel. We will be using this to be able to connect with the Pterodactyl panel.

This is an example of someone that uses the host name connect for their Minecraft server and control for their Pterodactyl panel. alt text

Setting up the panel VM

  • Start by opening PuTTY or your terminal and SSH into the newly created VM
  • Follow the same instructions described in updating the software
  • Update the firewall settings, this should be done for both the panel and server VM, copy the commands below and paste them in the terminals
apt install firewalld
firewall-cmd --permanent --zone=public --add-port=25565/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --permanent --zone=public --add-port=2022/tcp
firewall-cmd --permanent --zone=public --add-port=22/tcp
firewall-cmd --permanent --zone=public --add-port=5657/tcp
firewall-cmd --permanent --zone=public --add-port=56423/tcp
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload

Setting up pterodactyl

Paste the following command in the terminal of the panel VM

bash <(curl -s https://raw.githubusercontent.com/pterodactyl-installer/pterodactyl-installer/master/install.sh)

This will do a Q&A session with you where you need to fill in the following answers.

  • What would you like to do?
    • [0] Install the panel
  • Database name (panel)
    • press enter (use default)
  • Database username (pterodactyl)
    • press enter
  • Password (press enter to use a randomly generated password)
    • Just use a password that you can easily remember
  • Select timezone
  • Provide the email address that will be used to configure Let's Encrypt and Pterodactyl
    • Fill in your email
  • Email address for the initial admin account
    • Use the same email (can be different)
  • Username
    • admin
  • Fill in your first and last name
  • Set the FQDN of this panel (panel.example.com)
    • Use the following syntax: {panel host name}.{domain}.{suffix}
    • For instance panel.akkerman.ai is what I use
  • Do you want to automatically configure UFW?
    • N
  • Do you want to automatically configure HTTPS using Let's Encrypt?
    • y
  • I agree that this HTTPS request is performed
    • y
    • If all went well you should see a summary of the information you filled in. If this is not the case then check if you wrote the step for the FQDN correct and cancel it.
  • Initial configuration completed. Continue with installation?
    • y
  • Agree to everything else that is shown after this (terms and services, etc.)

Setting up wings

Paste the following command in the terminal of the Minecraft VM (this is the same command we used for the panel)

bash <(curl -s https://raw.githubusercontent.com/pterodactyl-installer/pterodactyl-installer/master/install.sh)
  • What would you like to do?
    • [1] Install Wings
  • Do you want to automatically configure UFW?
    • N
  • Do you want to automatically configure a user for database hosts?
    • y
  • Do you want to configure MySQL to be accessed externally?
    • y
  • Enter the panel address (blank for any address)
    • Use the following syntax: {panel host name}.{your domain}.{suffix}
    • For instance panel.akkerman.ai is what I use
  • Database host username (pterodactyluser)
    • press enter
  • Database host password
    • The password you filled in in the previous section
    • If you get a warning about Let's Encrypt you can ignore this
  • Do you want to automatically configure HTTPS using Let's Encrypt?
    • y
  • Set the FQDN to use for Let's Encrypt (node.example.com)
    • Use the following syntax: {minecraft server host name}.{domain}.{suffix}
  • I agree that this HTTPS request is performed
    • y
  • Enter the email address for Let's Encrypt
    • This is the same email address you filled in before
  • Proceed with installation?
    • y
  • Agree to everything else that is shown after this

Setting up the node

Now you can access your Pterodactyl website. Head to {panel host name}.{domain}.{suffix} and sign in. Before creating the node we need to create a location.

  • Click on the settings icon on the top right.
  • Click on Locations
  • Create new
  • Fill in the Short Code for instance, node, and save it

Now that we got the location we can create a new node.

  • Head to Nodes and create a new node
  • Add a name for instance, Main
  • FQDN: {minecraft server host name}.{domain}.{suffix}
  • Total memory: 24000
  • Memory Over-Allocation: 0
  • Total disk space: 45000
  • Disk over-allocation: 0
  • Leave the rest on their defaults
    • Unless you are using a proxy like Cloudflare, then set Behind Proxy
  • Click Create Node

Create node allocation

  • Open the newly created node
  • Click on the tab Allocation
  • Open your Minecraft VM terminal and paste this command
hostname -I | awk '{print $1}'
  • Copy the result of that copy
  • Paste that IP address in the IP Address field of Assign New Allocations
  • Fill in 25565 for Ports
  • Click on Submit

Use this image as an example. alt text

Starting Wings

To start wings on the Minecraft VM we need a token.

  • Go to the configuration tab of this node and click on Generate Token.
  • Copy the whole command and paste it into the console of the Minecraft server.
    alt text
  • To test if Wings is installed correctly you can run:
sudo wings
  • If this is correct you will see a green heart on the left of your node.
    alt text
  • Press CTRL+C in the console to exit wings
  • Use to following command so that Wings will run in the background
systemctl start wings

Creating a nest

  • Head to the Nests option in the sidebar
  • Click on Minecraft
  • Select Forge Minecraft in the options for Nest Eggs
  • In Configuration, you will find multiple lines in Docker Images, delete everything there
  • Go to pterodactyl-images and head to the section Java Eclipse Temurin [AMD64/ARM64]
  • Copy the correct Java version for your Minecraft version. You can find the Java version for each Minecraft version here
    • If you're using Minecraft version 1.20.1 this will be ghcr.io/software-noob/pterodactyl-images:java_17
  • Leave everything else to their defaults and hit save

Setting up the server

  • Head to Servers in the left sidebar
  • Click on Create New
  • Fill in the name of your server
  • Add yourself as the server owner, you can search by name and email address
  • Under Resource Management you can find Memory, I have set memory to 22000 but you can go for a lower number if you are using a vanilla server
  • Disk space: 43000
  • Egg: Forge Minecraft
  • Get the correct Forge version for your modpack and paste this in Forge Version under Service Variables. You can find this in the Curseforge app by clicking on the modpack you want to have as a server.
    alt text
    • So in my case, I fill in 1.20.1-47.2.18
  • Save
    If you click on the pop up button after creation you can see the terminal and the server should be starting now.

Debugging

During the starting of your server, you can run into this error.

Error Event [a42aeaba-5a57-4b31-b888-f76257c1ab0f]: environment/docker: failed to start container: Error response from daemon: driver failed programming external connectivity on endpoint 1ba18bdc-05e9-4b6a-be5e-9a2df92f965e (7ed1002d6be9d188a6400cf5b06d94ac04cd0940a9c3e60b991f639eb0e0c6f0): failed to bind port 10.0.0.236:25565/tcp: Error starting userland proxy: listen tcp4 10.0.0.236:25565: bind: address already in use

This means that a Minecraft server is currently running on your Minecraft VM, be sure to stop it.

Installing the Curseforge server

  • Head to the Files section of your preferred modpack
  • Click on the latest release and at the bottom next to the Changelog you will find Additional Files click on it.
  • Download the server pack
  • Extract the server pack and run the .bat or .sh file, depending on your OS. This will start the server locally and create some necessary files.
  • Wait for it to stop due to the eula.txt and exit
    • Craft to Exile 2 automatically sets the eula.txt to True so you can exit once the server is completely done loading
  • Delete the server .zip and zip the other files
  • Go to the Pterodactyl panel and create a new server
  • Wait for it to install everything.
  • Wait for the EULA popup and then close it. You will see that the console will output a message like this and then will stop: [main/INFO] [minecraft/Main]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
  • Go to the Files tab and delete the following files from the container
    alt text
  • Head to the Settings tab and SFTP into the server.
    alt text
    • In this case, the address is sftp://bad.47fd94fc@localhost:2022 and the password is the same as to access the panel. You can also press the Launch SFTP button and it will open WinSCP or any other client that you have installed.
    • Your SFTP password is the same as the password you use to access this panel.
  • After loading you will see the files that are still left in the container. Add the zip file we made earlier to it.
    • You can also delete the files from the previous step here.
  • After the uploading is done, go back to the file overview in the panel. Press the 3 dots behind the zip file and select Unarchive. This will unpack the zip file.
  • After unpacking, delete the .zip file to save space.
  • Open the user_jvm_args.txt file
    • Delete the command -XX:+AlwaysPreTouch
    • Copy everything else after -Xms8G -Xmx8G
    • Head to your servers and open the settings for the server you are making.
    • Click on the Startup tab and paste the copied content in Startup Command after -XX:MaxRAMPercentage=95.0
      alt text
    • Click on Save modifications
  • Start the server and accept the EULA
  • Everything should start and you can now access the server

Automatically restart every 6 hours

This is advised by the wiki of Craft to Exile 2.

  • To set this up head to Schedules of your server and click on Create schedule.
  • Give it a new, for instance 6 hourly restart
  • Use the following cron settings, or use this tool if you need a different timeframe
    • Minutes: 0
    • Hour: */6
    • Day (Month): *
    • Month: *
    • Day (Week): *
  • Click on New Task for the created schedule
    • Action: Send command
    • Payload: /say The server will be restarted in 1 minute
    • Enable: Continue on failure
  • Create a task for terminating the server
    • Action: Send power action
    • Payload: Terminate the server
    • Time offset: 60
    • Enable Continue on failure
  • Create another task, for starting the server
    • Action: Send power action
    • Payload: Start the server
    • Time offset: 70
  • To test that everything has been set correctly, click the Run Now button on the Schedules overview.
  • Head back to the server's console and wait for it to perform all actions.

Oracle Cloud Budget

If you are afraid of spending money on the virtual machines hosted in Oracle Cloud then you can set a budget.

  • Head to the Budgets overview in Oracle Cloud
  • Give it a name and description (mandatory)
  • Set the Budget Amount to 1
  • Set the Threshold Type to Absolute Amount
  • Set Threshold Amount to 1
  • Fill in your email
  • Save the budget

Acknowledgements