LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-14-2009, 10:19 PM   #1
¿F M J¿
Member
 
Registered: Feb 2004
Location: New Zealand
Distribution: Ubuntu Hardy Heron, Fedora Core 3
Posts: 45

Rep: Reputation: 15
Unhappy Hosting 2 domains - 1 ip


ok heres what im having problems with, have 2 domains for example i'll use these names

www.site1.net
www.site2.net

and have 1 IP address...

I use no-ip.com for reigstering and handling dns...

Have become utterly confused with the apache doc's and setting DNS a hosts and CNAME's and port 80 redirects etc...


i tried following this guide here

http://www.debian-administration.org/articles/18

But i have included ports for each domain

Doesnt seemed to have worked..

visiting www.site1.net - results in a blank white page and not the site i have in there...

I know it could also be a problem with my domain dns's so i'll explain settings below that i usee with those...

www.site1.com port-80 redirect to the IP and port that its setup on virtually wise...

www.site2.com - same method

.. basically the more i look and read, the more confused im becoming...

would love some advice/help
 
Old 05-14-2009, 11:17 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
see the apache docs
http://httpd.apache.org/docs/2.2/
and in particular the " Apache Virtual Host documentation"
http://httpd.apache.org/docs/2.2/vhosts/
 
Old 05-15-2009, 03:09 AM   #3
¿F M J¿
Member
 
Registered: Feb 2004
Location: New Zealand
Distribution: Ubuntu Hardy Heron, Fedora Core 3
Posts: 45

Original Poster
Rep: Reputation: 15
would love some useful advice/help, not links to stuff i've read and already having issues understanding due to it apparently not working as stated
 
Old 05-15-2009, 11:33 AM   #4
andresc889
LQ Newbie
 
Registered: Apr 2009
Distribution: openSUSE, Fedora, CentOS
Posts: 11

Rep: Reputation: 2
Talking

Hi,

As I understand your situation, you will need to use Name-based virtual hosts in Apache. This means that you only have one public IP that points to the same server and you need two different sites to be hosted in this server.

The first thing you need to do is make sure Apache works for a single site without any additional configuration. Depending on your version of Apache and your Linux distributon, configuration files might be located in different places and might vary slightly. In my case, I am using openSuSE 11.0 and Apache 2. My main configuration file is httpd.conf. It has a line like this:

Code:
Include /etc/apache2/vhosts.d/*.conf
This is just done to include a configuration file from a different folder in order to make Apache more modular. My virtual host configuration is located in /etc/apache2/vhosts.d/yast2_vhosts.conf

In this file, we have to tell Apache that we are going to use name-based virtual hosting for all IP addresses in port 80. We use the following directive:

Code:
NameVirtualHost *:80
Then, we have to configure each virtual host. This is what your virtual host configuration file is going to look like for your sites (I'll explain in a minute:

Code:
NameVirtualHost *:80

<VirtualHost *:80>
 ServerName site1.net
 ServerAlias www.site1.net
 ServerAdmin webmaster@site1.net
 DocumentRoot /srv/www/htdocs/www.site1.net/
 <Directory /srv/www/htdocs/www.site1.net/>
  AllowOverride None
  Order allow,deny
  Allow from all
 </Directory>
 DirectoryIndex index.html index.php
</VirtualHost>

<VirtualHost *:80>
 ServerName site2.net
 ServerAlias www.site2.net
 ServerAdmin webmaster@site2.net
 DocumentRoot /srv/www/htdocs/www.site2.net/
 <Directory /srv/www/htdocs/www.site2.net/>
  AllowOverride None
  Order allow,deny
  Allow from all
 </Directory>
 DirectoryIndex index.html index.php
</VirtualHost>
As you can see, the two virtual hosts are basically the same thing, except for the names of the hosts (site1.net vs site2.net). For each host, we have to specify the name and the aliases. The aliases are other names that Apache will use for this host. The DocumentRoot directive tells Apache where the files for this host are. Then, we use the Directory section to define permissions for the host. In this example, we are basically allowing the public to access the site, but we could easily tell Apache to allow a group of IP addresses. The DirectoryIndex directive tells Apache what the default file to show is if the client does not request an specific file. ServerAdmin is the administrator of the site.

You might wonder, what happens if the client requests the site by IP address instead of a name. As far as I know (can somebody verify this?), Apache will use the first defined virtual host as a default. In this case, that would be site1.net. Apache uses the HTTP request headers to determine which virtual host to use. Also, as far as I know (can somebody verify this too?), any directives that you don't define inside a VirtualHost section will have the value of the default server, which is probably configured in httpd.conf

After you have done all these changes, restart Apache.

Lastly, you need to configure your DNS server (which I assume is hosted at no-ip.com) to make the www.site1.net and www.site2.net point to the same IP address. This is the public IP of your web server. Also, you probably need to define these names inside your /etc/hosts file.

If you have any questions, I'll be happy to answer
 
Old 05-15-2009, 04:36 PM   #5
¿F M J¿
Member
 
Registered: Feb 2004
Location: New Zealand
Distribution: Ubuntu Hardy Heron, Fedora Core 3
Posts: 45

Original Poster
Rep: Reputation: 15
thank our very much for tat isightful and very helpful post.... it's help solve my problem, good stuff andresc889
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BIND DNS - MX, TXT and SPF records when hosting multiple domains on same machine? icebrian Linux - Networking 3 05-02-2011 08:21 AM
Email server hosting multiple Domains bence8810 Linux - Server 7 02-11-2007 02:53 PM
Apache: hosting multiple domains fturcic Linux - Software 1 02-15-2005 05:39 PM
Hosting multiple domains Imanerd Linux - Networking 2 01-04-2005 08:10 PM
Hosting my own domains on Linux with a router gomer1701ems Linux - Networking 5 02-16-2001 12:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration