I'm not sure if this should go in linux or web development but I expect I'll get more help here.
Basically, in conjunction with the web design class I'm having in school, I decided to try my hand at some servering. Being damn near a complete stranger to linux, I installed Ubuntu server edition on one of my spare comps. After a few weeks of dicking about with it on and off and reading numerous guides online, I finally got everything working with the domain I purchased.
Everything works great, but I want more than just one site running on it. Adding a new virtual host is simple enough, but what I'm not sure about is how I make for example site1.domain.com point to one site and site2.domain.com point to another, both hosted on the same computer.
I googled but can't find anything on specifically my problem. I bought the domain at name.com and the server is running ubuntu server 10.10 with the standard LAMP package installed.
-snip didn't read-
-snip- it's okay, i forgive you.
If you've already created the virtual hosts for site1.domain.com and site2.domain.com, you've done all you need to on the server. What you need to do next is create DNS records for those two names, pointing to the server's IP. That's something you typically do through the registrar where you bought the domain, unless you've pointed the domain at some other DNS server.
[QUOTE=Wyzard;29755702]If you've already created the virtual hosts for site1.domain.com and site2.domain.com, you've done all you need to on the server. What you need to do next is create DNS records for those two names, pointing to the server's IP. That's something you typically do through the registrar where you bought the domain, unless you've pointed the domain at some other DNS server.[/QUOTE]
Quite right, but the domain points to my IP. If I have two vhosts running on the same comp on the same IP, if I enter either site1.domain.com or site2.domain.com, how will it differentiate on which site to display?
[editline]11th May 2011[/editline]
Or rather, how do I go about making it display the correct site?
You basically have two different "DocumentRoots", one for each site. You could put one site in /var/www/site1, and another in /var/www/site2. Just set that up in your vhost configuration.
If you aren't using plain HTML or PHP, but instead something like Django or Ruby on Rails then its the same idea but you don't care about DocumentRoot. Django for instance has it's own variable for where the site is located.
This is assuming you have apache2 installed.
Setup two separate "DocumentRoots" as the above poster suggested, but here is the vhost configuration that I use that would run perfectly for you. Just change the values that you want and it will work right out of the box.
Replace /etc/apache2/httpd.conf with this:
[code]
NameVirtualHost <ip address>:80
<VirtualHost <ip address>:80>
ServerName site1.domain.com
DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost <ip address>:80>
ServerName site2.domain.com
DocumentRoot /var/www/site2
</VirtualHost>
[/code]
No, DNS is not capable of directory navigation. It can only point to IP addresses.
[QUOTE=chipset;29756438]Quite right, but the domain points to my IP.[/QUOTE]
What do you mean when you say "the domain"? We're talking about two different names here. "site1.domain.com" and "site2.domain.com" are different from just "domain.com" or something like "www.domain.com". You need to create address records in DNS for the names "site1" and "site2" in the "domain.com" zone, so that both of those names (not just "www.domain.com" or whatever) resolve to your server's IP.
Sorry, you need to Log In to post a reply to this thread.