Go to Services -> EC2 -> Launch Instances -> Choose the AMI (Amazon Machine Image) -> choose Instance Type -> Configure Instance Details.
I
If you want to see below page when you try to access the EC2 instance:
Then you need to add the below code in the “User Data” section. This will be launched only at the first boot of the instance.
#!/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
P.S.: Please add the code which seems to be like commented. If you don’t add the #!/bin/bash it will not work. I did the same mistake, I had not added thinking it as a commented code.
yum update -y => Update all softwares. YUM(Yellowdog updater) helps you to manage Linux softwares. -y means yes, it won’t ask you for the confirmation.
yum install httpd -y => installs the Apache http server
systemctl start httpd => start the httpd server
systemctl enable httpd =>when u restart the server the httpd server would also be restarted
Alternatively, you can run the above commands individually on the instance after it has been created. Don’t forget to execute below command to run the above command:
sudo su => to become a super user
Add Storage -> Add Tags -> Configure Security Group, Add HTTP to security group -> Review and Launch.
copy the Public IPv4 address or Public IPv4 DNS name and paste in the browser, make sure to edit the https to http or else your page may not load. And here you go…
The IP you are seeing is the Private IP.