Issue
I gave this code in user data but not able to load any page with the following public IP 35.173.240.157 or when I tried to open a text document. 35.173.240.157/test.html
> #!/bin/bash
> yum install httpd –y
>
> service httpd start
>
> chkconfig httpd on
echo “<h1> Hi! This is bootstrapping!</h1>”>/var/www/html/test.html
I expect the output that default apache page should be displayed and this text should be accessed note: I am using ubuntu
Solution
We need to know where the error is.
So log in to EC2, check if your commands were successfully executed, by running
service httpd status
if you get an error, httpd was not installed, and that means your file was probably not created, as the directory was not present.
do check that with:
ls -lrt /var/www/html
EDIT: I learnt that you don't need to be sudo when you're running a bootstrap script.
Answered By - EngineJanwaar