How to install apache server with a index.html page on Amazon Linux 2 AMI (HVM), SSD Volume Type (Bootstrap Script)

Amazon Linux 2 AMI (HVM), SSD Volume Type – ami-0e472933a1395e172 (64-bit x86)

#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
cd /var/www/html
echo "

This is WebServer 01

" > index.html

Or

#!/bin/bash
# Use this for your user data (script from top to bottom)
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Hello World from $(hostname -f)</h1>" > /var/www/html/index.html