How to setup web server accessed both with and without www?
13 Replies
ServerAlias example.com
ServerAlias
ServerAlias example.net
…
ServerName example.com
ServerAlias
DocumentRoot /srv/www/example.com/public_html/
ErrorLog /srv/www/example.com/logs/error.log
CustomLog /srv/www/example.com/logs/access.log combined
DNS have both example.com and
However, only
You might already have, but if not, try these:
Did you enable the site by running "sudo a2ensite example.com" which creaks a symbolic link in sites-enabled?
Look in the default file in sites-available. That might be intercepting the example.com requests. Try to change the document root in the default and reloading apache, "sudo /etc/init.d/apache reload"
That is all I can think of right now.
I look at default file. The document root is point to /var/www where is exactly where example.com goes now. However, I will have more than one domain on this server soon. The change on default file seems not a solution.
Thanks for your kind reply. I think there is something still not yet set correctly but I don't know where. What a headache…
I have about 20 domains on my Linode, but one of them is my primary domain name. I have that setup in the default file. That way if something is misconfiguration it points to the primary website. A misconfiguration is there is a DNS entry to my IP and there is no VirtualHost to catch the domain, it will default o the default site instead of loading the "It Works" page.
When i go to
But if i go to
Could you suggest where the problem might be?
Thanks
Abhishek
Not to be simple, but sometimes it is the simple things which get overlooked, so,…
Log in to your Linode account and go to Linode Manager
go to the DNS Manager tab.
Scroll down and look at A/AAAA Records
You will see fields for : Host Name IP Address TTL Edit Remove
The first row of entries has nothing in the first field - this makes your site
The second row should have www in the first field, and your ip address in the second field. This makes
In the following example both
[blank] 12.107.140.123 Default Edit Remove
www 12.107.140.123 Default Edit Remove
mail 12.107.141.456 Default Edit Remove
My A/AAAA Records are set up exactly the way you described it.
But still having the same problem.
@BarkerJr: My ServerName & ServerAlias are correct but still having the problem.
Any other suggestions?
This is particularly frustrating because it seems like everything is setup correctly. Here is my rendered DNS file from DNS Manager:
; underbellygames.com [60983]
$TTL 86400
@ IN SOA ns1.linode.com. 69e67145e8ee472d9ccd4fecb3dfbc61.protect.whoisguard.com. (
2009112308
7200
7200
1209600
86400
)
@ NS ns1.linode.com.
@ NS ns2.linode.com.
@ NS ns3.linode.com.
@ NS ns4.linode.com.
@ MX 20 ALT1.ASPMX.L.GOOGLE.COM.
@ MX 10 ASPMX.L.GOOGLE.COM.
@ MX 20 ALT2.ASPMX.L.GOOGLE.COM.
@ MX 30 ASPMX2.GOOGLEMAIL.COM.
@ MX 30 ASPMX3.GOOGLEMAIL.COM.
@ MX 30 ASPMX4.GOOGLEMAIL.COM.
@ MX 30 ASPMX5.GOOGLEMAIL.COM.
www A 74.207.252.118
mail A 74.207.252.118
@ A 74.207.252.118
I'm not sure if the order matters? I don't see any way to change the order.
Any ideas? Thanks!
But with a positive TTL of 86,400 seconds (the $TTL 86400 line), changes will take up to 24 hours to fully propagate. A smaller TTL (e.g. 3600) is recommended but not critical for this issue.
but
example.com would serve from /var/www/
My problem was with /etc/hosts. I had:
> 127.0.0.1 localhost.localdomain localhost hostname
123.45.67.89 example.com hostname
I removed the "example.com" domain from the second line, e.g.
> 127.0.0.1 localhost.localdomain localhost hostname
123.45.67.89 hostname
and now Apache serves both example.com and
Maybe this will help?