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 theArchitectureto64-bit (x86)inApplication and OS Images (Amazon Machine Image)and chooset2.microinInstance type
- Create a
AWSaccount - 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 searchEC2thenLaunch 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.mediumfor modded Minecraftt2.microfor Terraria
Key pair (login): Define how can you login to the instance safely.Create new key pairif 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:RSAis recommended for its higher security.Private key file format:.pemis recommended for many Linux machines have already installed it.Create key pairand select your key pair name.- It will generate a
.pemfile 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 settingsFirewall (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 detailsCreate a name so that you could know this security group is for your server.Inbound rules: add two rules, oneTypeisSSH(port22) and0.0.0.0/0as the source forSSHconnection; oneTypeisCustom TCPwhich has25565port rangewhich is the default port for Minecraft ServerOutbound rules: It might already exist thatAll trafficto enable internet connection, if no, create one.- Back to instance creation,
Select existing security groupand choose the security group you just created.
Configure storage: default8GiBwithgp3is 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 idyou 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 Instanceto start it. - Record
Public IPv4 addressorPublic IPv4 DNSas your instanceIPv4that would help you to connect to your instance - Use
OpenSSHcommand$ ssh -i PATH_TO_PEM.pem ec2-user@IPv4to 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, VERSIONand 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 --noguiinstead. -
Accept
EULA: 1. Openeula.txt:$ vim eula.txt, 2. Changeeula=falsetoeula=trueto indicate acceptance of theEULA
4. Launch the Server & Commands
- Launch Pure or Forge version
$ java -Xmx1536M -Xms512M -jar SERVER_NAME.jar --nogui-Xmx1024Mis maximum RAM allow server to use-Xms1024Mis 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
worldormodthen put the data into the folder