2

I had a domain transferred to amazon using their Rout 53. at the begining when i went to the IP address 54.69.253.182, or ec2-54-69-253-182.us-west-2.compute.amazonaws.com my site would show up. Currently I have set up some Record Sets in the hosted zones that direct the url(not sure if this is correct or not). Now if you go to either the IP address or the ec2 address it redirects to www.bracketfanatic.com and shows "Oops! Google Chrome could not find www.bracketfanatic.com Did you mean: www.­bracketfanatics.­com".

/etc/hostname : bracketfanatic.com apache2ctl configtest returns :

"sudo: unable to resolve host bracketfanatic.com 
AH00557: apache2: apr_sockaddr_info_get() failed for bracketfanatic.com
AH00558: apache2: Could not reliably determine the server's fully qualified domainname, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

sudo hostname ruturns:

sudo: unable to resolve host bracketfanatic.com
bracketfanatic.com

What I need: go to the url www.bracketfanatic.com or bracketfanatic.com it shows my site. I am brand new to amazon ec2, so please be specific. Any help or point in the right direction would be nice. If more information is needed, please just ask. Thank you.

enter image description here

1 Answer 1

3

Your host name also needs to be added to /etc/hosts in 127.0.0.1 section. If you haven't rebooted since editing /etc/hostname you also need to set the hostname using the hostname command. This normally happens at bootup from /etc/hostname.

Here is a script that I use to make sure the host name is set correctly on my Ubuntu ec2 instance:

#!/bin/sh
set -e

etchostname=`cat /etc/hostname`
if [ `echo "$etchostname" | grep -c '\.'` -eq 0 ]
then
    echo "ERROR: /etc/hostname does not contain a fully qualified domain name."
    echo "edit /etc/hostname and try again"
    exit 1
fi

if [ `grep 127.0.0.1 /etc/hosts | grep -c "$etchostname"` -eq 0 ]
then
    echo "Adding hostname to 127.0.0.1 in /etc/hosts"
    sudo sed -i -r "s/^127.0.0.1([ \t].*)/127.0.0.1 $etchostname \\1/g" /etc/hosts
fi

hostname=`hostname -f` || true
if [ "$hostname" != "$etchostname" ]
then
    echo "Setting hostname to $etchostname"
    sudo hostname "$etchostname"
fi

To solve the Apache message you will also have to create a configuration file for Apache using these commands source:

echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/servername.conf
sudo a2enconf servername
sudo service apache2 reload

You also need to set up DNS hosting for your website. To do so using route 53 you would log into the AWS admin console and navigate to route 53. You would then "Create hosted zone". In that hosted zone create records for the base domain (bracketfanatic.com.) and www.bracketfanatic.com. They could either be A records that point to your elastic IP address (54.69.253.182), or CNAME records that point to ec2-54-69-253-182.us-west-2.compute.amazonaws.com.

You will then need to copy the NS records from that hosted zone into your domain name registrar. If you are using GoDaddy, you would first "launch" your domain. Then you would choose "manage nameservers" and paste in the four values that Route 53 supplied for you.

12
  • thank you for the post. How do I run that script?
    – Sari Rahal
    Oct 30, 2014 at 16:48
  • You need to paste it into a file, make it runnable, and execute it. Try this: nano /tmp/hostname.sh && chmod +x /tmp/hostname.sh && /tmp/hostname.sh Oct 30, 2014 at 16:51
  • This script returns: ERROR: /etc/hostname does not contain a fully qualified domain name. edit /etc/hostname and try again I then changed /etc/hostname : bracketfanatic (removing the .com), and i get the same error.
    – Sari Rahal
    Oct 30, 2014 at 17:09
  • It should have the .com. The script is making sure that it does. echo bracketfanatic.com | grep -c '\.' gives me "1" (which shouldn't equal zero) so I'm not sure why the script is failing for you if "bracketfanatic.com" is what you have in /etc/hostname You can run cat /etc/hostname to check that it is set the way that you expect (with the .com) Oct 30, 2014 at 17:14
  • when i run "echo bracketfanatic.com | grep -c '\.'" gives me "1", and when i run "cat /etc/hostname" it returns bracketfanatic.com. Do i maybe need to restart apache2 or the instance for this to work?
    – Sari Rahal
    Oct 30, 2014 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.