This tutor is under Linux machine (my working and server machine is both using Linux), if you use Windows or Mac, please know how to open the terminal and install OpenSSH for connection.
# WHY
Learning something about AWS
, SSH
remote connection (ip
, port
, domain
), and java
usage.
Playing Minecraft with my friends when not under LAN
.
# WHAT
# HOW
*
means Optional Operation
# 1. Create an AWS EC2 Instance
Note. There is a free x86_64 CPU “
Free tier: In your first year includes 750 hours of t2.micro (or t3.micro in the Regions in which t2.micro is unavailable) instance usage on free tier AMIs per month, 30 GiB of EBS storage, 2 million IOs, 1 GB of snapshots, and 100 GB of bandwidth to the internet.
” for new user, but it is not very good for running Minecraft Server. But if you want to use it, you could follow the tutor, but you need to change theArchitecture
to64-bit (x86)
inApplication and OS Images (Amazon Machine Image)
and chooset2.micro
inInstance type
- Create a
AWS
account - Choose a good place that near your home on the top right of the AWS main webpage, e.g. I choose
US East (N. Virginia)us-east-1
- Look at the top left of the webpage, select
Services
-Compute
-EC2
-Instances
-Launch instances
, or you could just searchEC2
thenLaunch instances
- Create an instance for Minecraft Server
Name and tags
: Create a Name so that you could know this is your instance that run your Minecraft server.Application and OS Images (Amazon Machine Image)
: Define which types of CPU and System you would useAmazon Machine Image (AMI)
: Select a system for your instance. Amazon LinuxAmazon Machine Image (AMI)
is recommended for its cheapness (CPU under Linux Base System is cheaper) and lightweight (we do not need lots of functions to run Minecraft Server)Architecture
:64-bit (Arm)
is recommended because it has more CPUs with cheaper price. (Note. Terraria only support x86_64)
Instance type
: Choose a CPU for running Minecraft Server, here is a list of price for every CPU: AWS Price Calculator. Remind that a pure Minecraft server (No mod) with two people server needs at least 1 GiB RAMr7g.medium
for modded Minecraftt2.micro
for Terraria
Key pair (login)
: Define how can you login to the instance safely.Create new key pair
if you do not have one, otherwise you could choose one you know.Key pair name
: Create a name for your key pair so that you could know it is using for connection for your instance.Key pair type
:RSA
is recommended for its higher security.Private key file format
:.pem
is recommended for many Linux machines have already installed it.Create key pair
and select your key pair name.- It will generate a
.pem
file for instance authorization, remember to save it properly.- Create new path for storing if you do not have:
$ mkdir ~/.ssh
- Move file to the folder:
$ mv YOUR_PEM_FILE.pem ~/.ssh
- Change the permission to make the file safer:
$ chmod 400 ~/.ssh/YOUR_PEM_FILE.pem
- Create new path for storing if you do not have:
Network settings
Firewall (security groups)
: It is recommended that create a security groups independently and choose here.- In the left panel, select
Security Groups
-Create security group
Basic details
Create a name so that you could know this security group is for your server.Inbound rules
: add two rules, oneType
isSSH
(port22
) and0.0.0.0/0
as the source forSSH
connection; oneType
isCustom TCP
which has25565
port range
which is the default port for Minecraft ServerOutbound rules
: It might already exist thatAll traffic
to enable internet connection, if no, create one.- Back to instance creation,
Select existing security group
and choose the security group you just created.
Configure storage
: default8GiB
withgp3
is enough (even for my mods Server).- Turn to right panel
Launch instance
# 2. Connect Linux to the Instance with SSH
- Turn back to
instances
, select theinstance id
you just created - Then you open a new panel which lists all the detailed information for your instance. If the instance is not open, select
Instance state
-Start Instance
to start it. - Record
Public IPv4 address
orPublic IPv4 DNS
as your instanceIPv4
that would help you to connect to your instance - Use
OpenSSH
command$ ssh -i PATH_TO_PEM.pem ec2-user@IPv4
to connect to your instance. - *Before step 2.4, you might already have Minecraft Server file, you could transfer your file through
$ scp -i PATH_TO_PEM.pem -r SOURCE_FILE_OR_FOLDER ec2-user@IPv4:PATH_YOU_WANT_TO_STORE
# 3. Install Java & Minecraft Server to the Instance (After loginning in to your Remote Instance)
-
Install
Java 8
:$ sudo yum install java-1.8.0
-
Download Server Package
- 1.16.5 (No Mod):
$ wget https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar
- For other release, you could Google:
Minecraft, Server, VERSION
and look at the website in this format: https://www.minecraft.net/en-us/article/minecraft-java-edition-VERSION then scroll down to get the link - For mod Server, you could find here https://files.minecraftforge.net/net/minecraftforge/forge/ and download, but remind that later we will install it before first launch.
- 1.16.5 (No Mod):
-
First Launch:
$ java -jar server.jar --nogui
, if installforge
, then run$ java -jar forge-x.xx.x-installer.jar --installServer --nogui
instead. -
Accept
EULA
: 1. Openeula.txt
:$ vim eula.txt
, 2. Changeeula=false
toeula=true
to indicate acceptance of theEULA
# 4. Launch the Server & Commands
- Launch Pure or Forge version
$ java -Xmx1536M -Xms512M -jar SERVER_NAME.jar --nogui
-Xmx1024M
is maximum RAM allow server to use-Xms1024M
is minimum RAM allow server to use- Or you can launch by
systemd
:sudo touch /etc/systemd/system/minecraft.service
,sudo chmod 664 /etc/systemd/system/minecraft.service
,sudo vim /etc/systemd/system/minecraft.service
,sudo systemctl daemon-reload
- eg.
java -Xmx7680M -Xms1024M -jar forge-1.16.5-36.2.34.jar --nogui
[Service]
User=ec2-user
WorkingDirectory=/home/ec2-user/minecraft
ReadWriteDirectories=/home/ec2-user/minecraft
ExecStart=java -Xmx1536M -Xms512M -jar /home/ec2-user/minecraft/server.jar --nogui
ExecStop=/stop
- Stop the Server:
/stop
# 5*. Adding mods and worlds
- Before the second launch, create a new folder
world
ormod
then put the data into the folder