Step # 1:
- Search for EC2 in the search bar of console and select the first option.
Step # 2:
- Now click on the launch instance as shown below:
Step # 3:
- Write down the name of the server you want to create i.e server01. Now scroll down a little and in the quick start section select Amazon Linux, there is subsection name Amazon machine image (AMI), there select an option of amazon linux 2 AMI as shown below:
Step # 4:
- In the key pair section select processed without key pair, it is recommended if you want to add security like private and public key to execute the application.
Step # 5:
- Now go to the Network section and click on the edit on the right side. In the type section select the HTTP option as shown below':
Step # 6:
-
Now go to the advanced details and scroll down to the bottom, in the user data section, paste the code like shown below:
" >> index.html echo " " >> index.html echo " " >> index.html ...... ..... echo " " >> index.html echo "" >> index.html echo "" >> index.html
#!/bin/bash
sudo yum update -y
sudo yum install -y httpd
sudo yum install -y git
export META_INST_ID=curl http://169.254.169.254/latest/meta-data/instance-id
export META_INST_TYPE=curl http://169.254.169.254/latest/meta-data/instance-type
export META_INST_AZ=curl http://169.254.169.254/latest/meta-data/placement/availability-zone
cd /var/www/html
echo "<!DOCTYPE html>" >> index.html
echo "" >> index.html
echo "sudo service httpd start
Step # 7:
At last review the summary on the right side and click on the launch instance. The instance will be launched successfully.
Now open the instance section and click on the server created in order to check the status, as shown below:
Step # 8:
- After some time the instance will start running. The public IPV4 DNS will be provided in order to check the instance details, like in my case I have below link: http://ec2-3-86-106-163.compute-1.amazonaws.com/
After clicking on the above link it give below details:
It shows the successful creation of the instance along with the region given.
Top comments (0)