Md Amir Hasan
3 min readMay 21, 2021

--

How to setup basic ec2 machine on AWS and install basic Node/MySQL app

First, log in to your AWS and navigate to EC2. Launch a new instance.

AWS EC2 Setup

Create an account in AWS and go to EC2 in the aws Dashboard. In the AWS EC2 dashboard, you can see a launch instance button,

1. Choose an Amazon machine image

Select the Amazon EC2 AMI as per your requirements.

2. Choose an Instance Type

3. Configure Instance Details

For now, you can skip this step and leave the values to their defaults.

4. Add Storage

Skip storage as well. The predefined 8 GiB should be enough so far.

5. Add Tags

Here, click the link to add a name tag . This name will later appear in your instance overview.

6. Configure Security Group

This step is the important one. AWS recommends creating a new security group for this instance and we’re going to do this. Apply the inbound rules as following:

The value for My IP is added automatically. To connect and configure this instance via ssh from our computer and to access the instance via HTTP/HTTPS from everywhere.
Now head to “Review and Launch”

7. Review Instance Launch

”Launch“ to create this instance and create a new private key and give it a name. Don’t forget to immediately download it. You’ll need it later.

Press “Launch Instances”.

That’s it, you’re done and after the instance was successfully created we can connect to it via SSH.

Connect to Instance

In your terminal, navigate to the folder where your downloaded key pair is stored. In AWS select your initialized instance and click on “Connect”

Install MySQL server

yum install mysql-server

And when you are prompted, type ‘y’.

Then configure MySQL server to start up automatically on reboot if you want.

chkconfig mysqld on

Then start the MySQL

service mysqld start

Update password on your local MySQL server if you want,

mysqladmin -u root password [your_new_pwd]

Now we have installed MySQL server into our EC2 instance. Then we try to connect to login to the mysql server. If you have created a root user password then we can login to MySQL as follows:

mysql -u root -p

Then you will ask for the root user password and then enter a password, then you should see an output as follows.

Now we have installed MySQL into our EC2 instance.

Installing Nodejs in AWS EC2

Let’s install nodjs AWS EC2 using the command

curl -sL https://rpm.nodesource.com/setup_15.x | sudo -E bash

Now, Install the nodejs on Ec2 instance

sudo yum install -y nodejs

Node is installed successfully on the instance. you can test the nodejs by checking the version of nodejs and npm.

--

--