AWS Classroomnotes 22/Feb/2023

AWS EC2 contd…

Options for deploying applications into ec2 instance

  • Lets try to install php on apache server (ubuntu)
apt update
apt install apache2 stress -y
apt install php libapache2-mod-php php-mysql -y
echo '<?php phpinfo(); ?>' > /var/www/html/info.php
systemctl restart apache2
  • Options:
    • Create an ec2 instance, ssh and execute manually:
      • Create an ec2
      • ssh into ec2
      • become root user (sudo -i)
    • While creating an ec2 instance use user data
    • Create a reusable image (Amazon Machine Image)

Instance MetaData Service v1

  • Login into the ec2 instance
  • Instance Metadata service helps in fetching metadata about ec2 instnaces by sending http requests on
  • send a curl request curl
  • Refer Here for instance metadata categories
  • Userdata configured on ec2 can be accessed over

User Data

  • In the Advanced section of ec2 instance creation for ubuntu 22 with 80 port opened copy the script into user data and launch instance
  • User Data is the script that gets executed during ec2 creation which is also referred as provisioning.
  • Accesing the application over http://<publicip>/info.php should give php info page.

Creating an AMI

  • AMI id is used to create ec2 instances which is scoped to a Region.
  • If we want AMI in multiple regions, we need to copy and this leads to new AMI id.
  • Note:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner