AWS Classroomnotes 22/Feb/2023

AWS EC2 contd…

Options for deploying applications into ec2 instance

  • Lets try to install php on apache server (ubuntu)
#!/bin/bash
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

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
    Preview
  • User Data is the script that gets executed during ec2 creation which is also referred as provisioning.
    Preview
    Preview
  • 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.
    Preview
    Preview
    Preview
  • 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