I want to create a subdomain from a real, living site which I will call example.com. The subdomain has to be named subdomain.example.com. Everything is running on a Amazon EC2 instance.
I just can't access the subdomain.example.com, when trying to access this URL, the browser shows the usual "Server not found" message.
I followed the next steps (includes steps from other StackOverflow answers):
1.-Acquired the domain example.com at GoDaddy.
2.-Linked correctly the example.com website to the real server, so the main site works fine.
3.-Went to the Amazon EC2 Console and created a EIP (Elastic IP)
4.-Went to Route53 and added a new Hosted Zone just like this article says (http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingNewSubdomain.html)
So that at I can see the subdomain.example.com Hosted Zone, and inside it there is a A Record that points to my Elastic IP.
5.-Went to the server and checked that the line "NameVirtualHost *:80" is there.
6.-Created a Virtual Host directive like the next one:
<VirtualHost *:80>
ServerName subdomain.example.com
ServerAdmin webmaster#subdomain.example.com
DocumentRoot /opt/bitnami/frameworks/codeigniter/htdocs
<Directory /opt/bitnami/frameworks/codeigniter/htdocs>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/subdomain.example.com.log
LogLevel warn
CustomLog /var/log/apache2/subdomain.example.com.access.log combined
</VirtualHost>
7.- Restarted the apache server
However, as stated at the start of the post, I can't ping or access the website.
What step could I be missing?
Are there chances that the change hasn't been propagraget yet? One day after the subdomain creation I'm still unable to access the website.
Ok, thanks to #Sergey and #datasage, the updated step list:
4.1- Go to your GoDaddy account (or your alternate provider) and add the 4 addresses obtained from Route 53 Hosted Zones, these addresses are under the label "Delegation Set".
4.2- Wait for about an hour until the changes are done (in my case it worked instantly for some reason)
Here is an useful article about these steps: http://blog.sefindustries.com/redirect-a-subdomain-to-route-53-from-godaddy/
Check subdomain.example.com, if record exists in DNS or propagated well:
Ask you default "home" DNS server
dig -t A subdomain.example.com
Ask google dns
dig -t A subdomain.example.com #8.8.8.8
Ask your authorized DNS server
dig -t A subdomain.example.com #your.ns.server
In case of windows use nslookup
or
Use internet service (for example digweb)
Related
I am trying to set up 2 domains (domain1.com and domain2.com) with a few subdomains (app.domain1.com) in AWS and run them on single instance (Amazon Linux, PHP, MySQL).
I have set up 3 hosted zones in AWS Route53 with following configurations.
Hosted zone 1:
domain1.com
Type A
52.108.XX.YY
Hosted Zone 2
domain2.com
Type A
52.108.XX.YY
Hosted Zone 3
app.domain1.com
Type A
52.108.XX.YY
Additionally, I have added following code to the http.conf file in VirtualHost tag.
<VirtualHost *:80>
ServerName domain1.com
DocumentRoot "/var/www/html/domain1"
ErrorLog "logs/domain1-error_log"
CustomLog "logs/domain1-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerName domain2.com
DocumentRoot "/var/www/html/domain2"
ErrorLog "logs/domain2-error_log"
CustomLog "logs/domain2-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerName app.domain1.com
DocumentRoot "/var/www/html/app"
ErrorLog "logs/app.domain1-error_log"
CustomLog "logs/app.domain1-access_log" common
</VirtualHost>
However, only domain1.com and domain2.com are getting resolved. When I visit app.domain1.com, it gives me a "can't find server" error. Please help how to setup the subdomain - is there problem in Hosted Zone setup or httpd.conf?
Ok, so after about 2 hours of reading up various sites and tinkering, I am all set. Here is how to do this.
Basically, you should not have more than 1 hosted zone (HZ) per domain name, otherwise things are really going to be bad. If you have more than 1 HZ for a domain name, please delete the one that was created for the subdomain.
Each HZ will have 4 records -
Following two records are created by default. Do not edit/delete them.
NS - This is the name server record. If AWS Route53 is not your registrar, use ns-servernumber.awsdns-number.com. and other three (4 total) records to change name servers for your registrar.
SOA - Let this record be. DO NOT TOUCH THIS.
Create following two Record Set (blue button).
A - Leave Name blank. Select A-IPv4 address for Type. In Value enter the IP address for your Elastic Load Balancer or EC2 instance.
CNAME - Add * (asterisks/wildcard) in the name field. Select CNAME from the drop down for Type In Value enter the domain name.
Now create the http.conf file and structure virtual hosts like I have in the question.
Things should work now :)
You can follow the tutorial on this link: http://brianshim.com/webtricks/host-multiple-sites-amazon-ec2/
A common error, according to the link, is:
Did it work? If not, here is one possible cause. There might be
another configuration file interfering with this one. Check for
another .conf file in /etc/httpd/conf.d. Often your primary
httpd.conf will include another .conf file in this directory. Make
sure it doesn’t have some Virtual Host settings which are interfering
with yours.
After you set the configurations, you should run:
sudo service httpd restart
This can be done installing Apache HTTP Server on AWS-EC2 instance and configuring VirtualHost for each DNS or Sub-DNS as suggested by an Amazonian
For brevity read this thread discussion, this official example and techrepublic post.
Hope this helped!
First of all, apologies for my English.
I've been reading and reading guides last week a lot hours with no success. I bought a domain + hosting but due bad performance I've got a cheap vps to use as hosting. Currently my setup is:
A domain .com with an A record pointed to my vps ip.
A unmanaged vps with Ubuntu 14.04.2 64 bits to use as hosting for my wordpress with LAMP stack with default setup (I didn't changed any setting on apache, using default virtualhost).
My site works fine but I'm don't know how create subdomains with different directories. For example, my website.com files are in /var/www/html and I'd like to create subdomain.website.com with the files in other directory, let's say /var/www/subdomain.
I checked a lot tutorials and they say to create a virtual server on apache (I use webmin) and then an A record for the subdomain pointing to the server ip.
The problem is that when I enter to subdomain.website.com I see the content from main domain (/var/www/html) and not from "/var/www/subdomain"
I don't want ask you for a full guide step by step, I just need know where I need to start for achieve a subdomain with a different directory because usually I always used hosting services with tools like cpanel to create subdomains pointed to directories in 2 clicks.
I'm a full newbie with Apache/dns management.
Thanks a lot for your time!
Create a virtual host in Apache by creating a file at /etc/apache2/sites-available/subdomain.website.com.conf
In that file, add the following
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName subdomain.website.com
DocumentRoot /var/www/subdomain.website.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now place your subdomain.website.com files at
/var/www/subdomain.website.com/public_html
Then enable the new virtual host by sudo a2ensite subdomain.website.com
After placing the files, if you get a 403 forbidden error, check for permissions of the DocumentRoot folder.
Refer: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
Instead of negative votes, how about telling my why . . .
I have set up a web server and uploaded some webpages on a LAMP stack. I am able to access via IP address. I set up my domain host to point to cloud dns. I enabled the cloud DNA api. My issue is that the domain is not loading the site, just returns "This webpage is not available / DNS lookup failed" I have read and tried a lot of different options. No Luck. Additional information:
sudo apache2ctl -S returns:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server lamp-6kvi.c.united-yeti-790.internal (/etc/apache2/sites-enabled/lamp-server:1)
port 80 namevhost lamp-6kvi.c.united-yeti-790.internal (/etc/apache2/sites-enabled/lamp-server:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/lamp-server:28)
port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com:1)
Syntax OK
The config file /etc/apache2/sites-available/example.com reads:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/websitedirectory
<Directory /var/www/websitedirectory/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/mysite-error.log
CustomLog /var/log/apache2/mysite-access.log common
cloud dns managed-zone list returns:
[
{
"creationTime": "2014-12-14T15:40:29.066Z",
"description": "",
"dnsName": "example.com.",
"id": "2608871832699155245",
"kind": "dns#managedZone",
"name": "exampledns",
"nameServers": [
"ns-cloud-d1.googledomains.com.",
"ns-cloud-d2.googledomains.com.",
"ns-cloud-d3.googledomains.com.",
"ns-cloud-d4.googledomains.com."
]
}]
I have not tried deleting the lamp-server, default or commenting out the other files . . . Please help.
To expand on your own answer, (by using web console) in general you should:
Go to your GCE Console, and
select your project.
Create the zone: In the left menu, go to Networking->Cloud DNS, then "Create Zone". Set the domain (example.com) and a name of your choice there. Once you create the zone, you will be taken to the record list of the zone.
Find the NameServer registers (the NS register type): You should see something like: ns-cloud-c1.googledomains.com, ns-cloud-c2.googledomains.com...
Set up these name servers with your Domain Registrar to make the domain accessible: go to the Registrar where this domain belongs to (NetworkSolutions/GoDaddy/Any Other), and configure the Name Servers (NS) for your domain. Set up the 4 you found in the previous step (don't just use the ones in my example, they're different for every zone you create).
Add the records you need to your zone: Go back to your GCE Console, to the Zone you just created in step 2. Click on "Add Record Set". In your case, what you need is a CNAME record: type "www" in DNS NAME, pick "CNAME" from RESOURCE RECORD TYPE, then type "example.com." as the CANONICAL NAME (notice the . at the end). Then click "Done".
You should now resolve both, example.com and www.example.com to the same IP. You also need to keep:
ServerName example.com
ServerAlias www.example.com
in your virtual host apache configuration.
Hope it helps clarify.
got it working - found out that you need to "add record set" type a for both www.example.com and example.com while pointing the ip to your server. set up virtual hosts like my question but without the section.
wish somebody would confirm that this was the proper way. anyways, added 4 more domains using the same method to the same server. :-D
I have set up my OVH server, installing apache2, php5, mysql, phpmyadmin etc... And configured the vhosts.
The content of my VirtualHost file :
<VirtualHost *:80>
ServerName www.abracadabook.fr
ServerAlias abracadabook.fr *.abracadabook.fr
DocumentRoot /home/abracadabook/www/
<Directory /home/abracadabook/www/>
Options -Indexes
AllowOverride All
</Directory>
</VirtualHost>
When I type the ip address of my server, it displays the apache default page. But after setting up my windows hosts file (I'm on windows but the server's on linux), when I try accessing abracadabook.fr the site is loaded and the root directory is right (/home/abracadabook/www) and it displays the normal index of my website. But the problem is that the site is not accessible from another client machine.
When I try to access to it from a PC which host file is not set up, nothing will load even when I access it with the ip address.
I searched in many boards and forum but never found the solution.
I hope you can help me.
Regardly,
(PS Sorry for my bad english)
Turns out I had not the good informations.
I followed this tutorial step by step and it works well now.
Kimsufi DNS setting Tutorial (French)
I have a cakephp web app which I've uploaded and linked to an apache server on an ubuntu Amazon EC2 instance under domain name ec2xxxx.compute.aws.com. The cake app is lying in the root of apache in /var/www/Cakefolder/ and opens directly on opening above link. I have bought a domain www.mywebsite.com I now wish to link the production alpha version of cake app with my domain under a subdomain link like alpha.mywebsite.com and have just a banner on www.mywebsite.com. I wrote the following code in a file I created called mywebsite.com.conf in etc/apache2/sites-available/ :
<VirtualHost alpha.mywebsite.com>
ServerAdmin webmaster#localhost
ServerAlias www.alpha1.mywebsite.com
DocumentRoot /var/www/cakeFolder
#if using awstats
ScriptAlias /awstats/ /usr/lib/cgi-bin/
CustomLog /var/log/apache2/mywebsite.com-access.log combined
</VirtualHost>
and then I added the following to etc/hosts file :
127.0.0.1 localhost.localdomain localhost alpha1.mywebsite.com www.alpha1.mywebsite.com
Right after doing this, my ec2 instance started displaying page unavailable and I cannot connect to the instance using putty or filezilla using ec2.aws.com dns or even elastic IP address. I have not yet linked it to the domain registrar, could that be the problem?
Please help!
This has nothing to do with your virtual host configuration. When you have attached an EIP, the instance would drop the Public DNS name. So that is out of picture.
Now, could you check and ensure that the EIP is still attached to the instance. OR to reconfirm, could you detach the EIP and re-attach it. Also, there is an option called "Get System Log" as shown below. Click on that and see whether you find any suspicious messages:
The SSH connection is independent of your apache configuration and this could be just a coincidence.