- Newest
- Most votes
- Most comments
Hello Vijay,
I hope you already have found answer by now, incase not then it is related to permissions. Once you have installed apache server it internally uses ec2-user which by default have no permissions to create files so you need to assign those permissions. You can use below script to make it work.
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
find /var/www -type f -exec chmod 0664 {} \;
echo " <h1> Hello world from $(hostname -f) </h1> " > /var/www/html/index.html
Hi Vijay,
Can you please check the Apache Configuration file at /etc/httpd/conf/httpd.conf, if there are no conflicting configurations that might be affecting the display of your custom index.html file.
Thanks
Atul
Hello.
It is executed with the following user data.
The AMI uses Amazon Linux2023.
#!/bin/bash
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
I believe this is because the default document is configured to be index.php and not index.html
If you connect to your public IP address /index.html this will rerun your hello world.
/index.php will return it works.
You have 2 options. Update the default document configuration or echo your hello world into index.php
I tried so many things, but its working if i delete the key pair. Not sure why. and once its started working if i attach it again, still its working. I really dont know the reason behind it. but right now its working if i delete the key pair.. I will try to find the reason in coming days and post it. Thank everyone for your response and suggestion.
The key pair is only needed for direct ssh access. So I’m dubious it makes a difference
Relevant content
- Accepted Answerasked 5 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
Thank you @Harmesh Choubisa! This one worked perfectly for me. I am surprised it is still not upvoted :)