Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Oct 27, 2009 3:02 am 
Offline
Newbie

Joined: Tue Oct 27, 2009 12:42 am
Posts: 3
I follow the guideline of web server setup in Linode Library and successfully setup a web server on Ubuntu 9.04. However, it can only work with www prefix. How can I setup the web server so that it can also accessed without www?


Top
   
 Post subject: ServerAlias
PostPosted: Tue Oct 27, 2009 5:57 am 
Offline
Junior Member
User avatar

Joined: Sun Oct 02, 2005 11:54 am
Posts: 43
Website: http://www.garyscott.net
Location: Goleta, CA
If you are using Apache, you setup a ServerName with the main domain name for that site and a ServerAlias for each additional domain name you want for that site. You can have only one ServerName but many ServerAlias. As long as there is a DNS entry for these pointing to your IP, you will be good to go.


<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAlias www.example.net
ServerAlias example.net
...
</VirtualHost>


Top
   
 Post subject:
PostPosted: Tue Oct 27, 2009 9:21 am 
Offline
Newbie

Joined: Tue Oct 27, 2009 12:42 am
Posts: 3
I follow the guideline at http://library.linode.com/web-servers/apache/installing-apache-ubuntu-jaunty and have created a file of /etc/apache2/sites-available/example.com with the following content:

<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /srv/www/example.com/public_html/
ErrorLog /srv/www/example.com/logs/error.log
CustomLog /srv/www/example.com/logs/access.log combined
</VirtualHost>

DNS have both example.com and www.example.com A/AAAA records point to my IP.

However, only www.example.com can access the expected web server. After some trial, I observe the example.com will access the content at /var/www/ instead of /srv/www/example.com/public_html/. Any idea?


Top
   
 Post subject:
PostPosted: Tue Oct 27, 2009 9:39 am 
Offline
Junior Member
User avatar

Joined: Sun Oct 02, 2005 11:54 am
Posts: 43
Website: http://www.garyscott.net
Location: Goleta, CA
Well you have it setup exactly like I do. So where could the problem be.

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.


Top
   
 Post subject:
PostPosted: Tue Oct 27, 2009 11:40 am 
Offline
Newbie

Joined: Tue Oct 27, 2009 12:42 am
Posts: 3
yes, I have run a2ensite. I saw there is a sym-link of example.com in sites-enabled directory.

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...


Top
   
 Post subject:
PostPosted: Tue Oct 27, 2009 12:51 pm 
Offline
Junior Member
User avatar

Joined: Sun Oct 02, 2005 11:54 am
Posts: 43
Website: http://www.garyscott.net
Location: Goleta, CA
I was suggesting to change the DocumentRoot in default to test that, that is the config that is intercepting your non www site. IF you find it is so, then change it back and then you know where to proceed.

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.


Top
   
PostPosted: Fri Nov 13, 2009 1:03 pm 
Offline
Senior Newbie

Joined: Fri Nov 13, 2009 12:36 pm
Posts: 5
I have configured apache for virtual host.

When i go to www.mysite.com , i get the right index page

But if i go to http://mysite.com , i get the apache default page - "it works"

Could you suggest where the problem might be?

Thanks
Abhishek


Top
   
 Post subject:
PostPosted: Fri Nov 13, 2009 5:51 pm 
Offline
Senior Member

Joined: Sun Aug 02, 2009 1:32 pm
Posts: 222
Website: https://www.barkerjr.net
Location: Connecticut, USA
Verify your ServerName and ServerAlias settings.


Top
   
PostPosted: Fri Nov 13, 2009 6:36 pm 
Offline
Junior Member
User avatar

Joined: Wed Jan 16, 2008 1:23 pm
Posts: 30
ICQ: 640975757
Website: http://cybrcaf.net
Location: half-way between my ears
Are your DNS Record settings correct?

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 http://example.com show up - and it should have your ip address in the second field of that row.
The second row should have www in the first field, and your ip address in the second field. This makes http://www.example.com show up. You can have more entries, for example, to your mail - or other subdomains.

In the following example both http://example.com and http://www.example.com will resolve to the same ip address - while http://mail.example.com will resolve to another ip address.

[blank] 12.107.140.123 Default Edit Remove
www 12.107.140.123 Default Edit Remove
mail 12.107.141.456 Default Edit Remove


Top
   
PostPosted: Mon Nov 16, 2009 11:20 am 
Offline
Senior Newbie

Joined: Fri Nov 13, 2009 12:36 pm
Posts: 5
@Kjb thanks for the detailed reply and guidance.

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?[/img][/list][/list]


Top
   
 Post subject:
PostPosted: Mon Nov 23, 2009 2:39 am 
Offline
Junior Member

Joined: Mon Nov 23, 2009 2:38 am
Posts: 22
I'm having the exact same problem. Has anyone found the solution for this yet?


Top
   
PostPosted: Mon Nov 23, 2009 3:08 am 
Offline

Joined: Mon Nov 23, 2009 3:04 am
Posts: 1
I'm having the same exact problems...

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!


Top
   
 Post subject:
PostPosted: Mon Nov 23, 2009 4:08 pm 
Offline
Senior Member

Joined: Sat Dec 04, 2004 5:36 pm
Posts: 145
No, order doesn't generally matter.

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.


Top
   
 Post subject:
PostPosted: Mon Nov 23, 2009 4:43 pm 
Offline

Joined: Mon Nov 23, 2009 4:33 pm
Posts: 1
I recently signed up here, somewhat of a linux newb, and had the same problem. I followed the tutorial in the wiki concerning Virtual Hosts and found that

www.example.com would serve from /srv/www/example.com/public_html/

but

example.com would serve from /var/www/

My problem was with /etc/hosts. I had:
Quote:
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.
Quote:
127.0.0.1 localhost.localdomain localhost hostname
123.45.67.89 hostname


and now Apache serves both example.com and www.example.com correctly, i.e. from /srv/www/example.com/public_html

Maybe this will help?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group