❌

Reading view

There are new articles available, click to refresh the page.

AWS : Connect EC2 in Terminal (Ubuntu) & Installing Apache2.

Prerequisite :

  1. Make sure the EC2 instance running in AWS.
  2. Key-pair to connect EC2

Step#1 :

Open the terminal in Ubuntu OS and move to directory where *.pem file saved in local. Then verify the file permission of the file.

devops@kaniyam:~/Desktop/Ponnarasu/Devops$ stat -c %a Ubuntu_Demo_server_key.pem
644

Step#2 :
Change the File permission to 600, which mean, only owner has access to read and write file and other doesn't have access.

devops@kaniyam:~/Desktop/Ponnarasu/Devops$ chmod 600 Ubuntu_Demo_server_key.pem
devops@kaniyam:~/Desktop/Ponnarasu/Devops$ stat -c %a Ubuntu_Demo_server_key.pem
600

Step#3 :
Connecting EC2 instance in Terminal by SSH.( SSH terminal should be open in EC2 ).

devops@kaniyam:~/Desktop/Ponnarasu/Devops$ **ssh -i Ubuntu_Demo_server_key.pem ubuntu@3.98.120.128**
The authenticity of host '3.98.120.128 (3.98.120.128)' can't be established.
ED25519 key fingerprint is SHA256:lNe/eooCjYSwIbu3p5HkbkB+WoW6I897bn0TaCBAYss.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '3.98.120.128' (ED25519) to the list of known hosts.
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-1012-aws x86_64)

Step#4 :
Update the Ubuntu OS

ubuntu@ip-172-31-1-176:~$ **sudo apt-get update**
Hit:1 http://ca-central-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://ca-central-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]

Step#5 :
Set/update the root password using below command.

ubuntu@ip-172-31-1-176:~$ **sudo passwd root**
New password:
Retype new password:
passwd: password updated successfully

Step#6 : Command to find the Public IP in terminal.

`ubuntu@ip-172-31-1-176:~$ curl ifconfig.me
3.98.120.128

ubuntu@ip-172-31-1-176:~$ curl icanhazip.com
3.98.120.128

ubuntu@ip-172-31-1-176:~$ curl http://checkip.amazonaws.com
3.98.120.128
`

Installing APACHE2 in Instance.

buntu@ip-172-31-1-176:~$ sudo apt install apache2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:

Start :
ubuntu@ip-172-31-1-176:~$ sudo systemctl start apache2
ubuntu@ip-172-31-1-176:~$ sudo systemctl enable apache2

Status :
ubuntu@ip-172-31-1-176:~$ sudo systemctl status apache2

Image description

Open the Apache Webserver in Firefox.

Failed to Open.
Image description

Cause :
Only SSH port is on the EC2 Instance, so Apache server not connecting.

Adding http: port in the security group .

Step#1 :
Existing Security Group :
Image description

Step#2 :
Add rule by clicking the "Add Rule" button.
Image description

Step#3 :
Choose the Type as "HTTP" and select source as "0.0.0.0/0" to connect the public IP from anywhere.

Image description

After adding the New security rule.

Image description

Refresh the Apache page :

Image description

AWS : EC2 Creation

What is EC2 ?

EC2 is a Virtual Server offer by Amazon to running the application on AWS.

Installing ES2 in AWS.
Step# 1 :
Login to Your AWS account and go to the ES2 Dashboard.

Image description

Step# 2 :
In the EC2 Dashboard, Click the "Launch Instance" button(Orange color).

Image description

Step# 3:
In the Launch Instance Page, Name your new Web server/Virtual Server and selecting OS Image ( AWS Linux, Ubuntu, Windows, Redhat) then choose the Latest version of the OS and Architecture.

Image description

Image description

Step#4:
In the Launch Instance Page, Choose the Instance type( No. of CPU's , Memory ) Re command is t2.micro for the study purpose, go head with higher performance machines for Organization purpose.

Image description

Step# 5:
Creating Key Pair and it used to open your ES2 instance in your machine.

Image description

Name the Key pair file and choose the RSA decryption/encryption algorithm then save the file *.pem in Local, don't share it.

Image description

Step# 6:
Configure Network Settings on your EC2 instance.

Image description

By clicking "Edit" button, you can change the configuration.
Enable the "Auto-assign public IP" to connect your instance in public. Create and name your Security group to controlling the port access. We are open the ssh port to connect the EC2 from my local machine.

Image description

Step #7: Storage.
Choose the appropriate storage to be require for the application. Re command would be 8GB for learning purpose.

Image description

Step# 8:
Creating/installing the EC2 instance by click the "Launch Instance" button. You can create more than one instance with this configuration by change the "Number of Instance".

Image description

Below page will be navigate once EC2 successfully running.

Image description

Step# 9 :
By clicking the "Instance ID", we can see the all the configuration of EC2.

Image description

Image description

Detach/Terminate Instance

Step #1:
In EC2 dashboard, Choose the instance name from list and select the Instance State drop down. It will show instance states, Stop, start, terminate, etc.

Image description

Choose the Instance state "Terminate Instance" will detach the instance which are choose in the Dashboard.

Image description

Choose the "Terminate" button on the pop-up screen.

Image description

Will take few minutes to terminated the EC2 Instance.

Image description

Image description

❌