AWS Set up

tags: AppWorks

pohanlu

Mon, Sep 5, 2022

Create account

  1. Click 👉 here 👈 to sign up AWS account
  2. Follow the steps to finish Identity authentication
  3. Log in your AWS account

Create a key pair

  • AWS uses public-key cryptography to secure the login information for your instance.
  • You specify the name of the key pair when you launch your instance, then provide the private key when you log in using SSH.
  1. Click 👉 here 👈 and choose Create key pair!
  2. Follow the graph to fill and choose
    • For Name, enter a descriptive name for the key pair.
    • Amazon EC2 associates the public key with the name that you specify as the key name.
  • Private key file is automatically downloaded by your browser.
  • This is the only chance for you to save the private key file.
  1. If you will use an SSH client on a macOS or Linux computer to connect to your Linux instance, use the following command to set the permissions of your private key file.
chmod 400 key-pair-name.pem

Create a security group

  • Security groups act as a firewall for associated instances, controlling both inbound and outbound traffic at the instance level.
  • You must add rules to a security group that enable you to connect to your instance from your IP address using SSH.
  • If you plan to launch instances in multiple Regions, you'll need to create a security group in each Region.
  1. Click 👉 here 👈 to open Amazon EC2 console
  2. From the top navigation bar, select a Region for the security group.
  3. After choose region, next is to Create security group
  • For Inbound rules, create rules that allow specific traffic to reach your instance.
  • Use the following rules for a web server that accepts HTTP and HTTPS traffic.
    • Adding following rules for Inbound rules

      Type Source
      HTTP Anywhere
      HTTPS Anywhere
      SSH My IP
    • For security, do not choose Anywhere for Source for SSH.

  • For Outbound rules, keep the default rule, which allows all outbound traffic.
  1. Then, choose Create security group

Create instance

AppWorks environment setup

  • Instance type should be t2.micro.
  • Machine image should be Amazon Linux 2 AMI.
  • Attach 8GB General Purpose SSD storage at least.
  1. Click 👉 here 👈 to open Amazon EC2 console
  2. Choose Launch instance and choose what you need
    • From Amazon Machine Image (AMI), select an HVM version of Amazon Linux 2
    • From Instance type, choose the t2.micro instance type
  3. Under Key pair (login), choose the key pair that you created when getting set up.
  4. Next to Network settings, choose Select existing security group.
  5. Final is Configure storage, choose 1x 8 GiB gp2 Root volume
  6. Review your instance configuration in the Summary panel (right hand side)
  7. Then, choose Launch instance

Connect to instance

  1. Click 👉 here 👈 to check the instance
  2. Choose the instance and click Connect
  3. Choose SSH Client and follow the steps

Install Node.js on instance

  1. Connect to your Linux instance as ec2-user using SSH
  2. Install node version manager (nvm)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
  1. Activate nvm
. ~/.nvm/nvm.sh
  1. Use nvm to install the latest version of Node.js
nvm install --lts
  1. Check Node.js is installed or not
node -e "console.log('Running Node.js ' + process.version)"

Install MySQL Server

  1. Connect to your Linux instance as ec2-user using SSH
  2. Need to update privileges to root user before installing the MySql
sudo su

若出現下列錯誤:you need to be root to perform this command

  • Sol. 輸入 su,按下 enter,並輸入密碼
  • 忘記密碼時,輸入 sudo passwd,重置密碼,再輸入su
  1. Updates all packages to the latest version
sudo yum update -y
  1. Install MySQL
sudo yum install -y mariadb-server

To Enable mysql to start when system reboots
Enter sudo systemctl enable mariadb

  1. We need to secure the installation
sudo mysql_secure_installation

Then, it will ask you a few questions,

  • Q: Enter current password for root ( enter for none ) :
    • A: Just press enter
  • Q: Set Root password? [Y/n]
    • A: Type ‘y’ and then press enter
  • Q: Remove anonymous user? [Y/n]
    • A: type ‘y’ and press enter
  • Q: Disallow root login remotely? [Y/n]
    • A: type ‘y’ and press enter
  • Q: Remove test database and access to it? [Y/n]
    • A: Type ‘y’ and press enter
  • Q: Reload privilege tables now? [Y/n]
    • A: Type ‘y’ and press enter
  1. Connect to MySQL, and you will see Welcome to the MariaDB monitor
mysql -uroot -p