LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 08-12-2004, 05:12 PM   #1
xtra
LQ Newbie
 
Registered: Jun 2004
Posts: 20

Rep: Reputation: 0
Yet another apache domain/subdomain problem


Sorry. I have found a million threads that are about it, I read them all, I tried almost every configuration but it just-wont-work!

I have an apache server with redhat 9. A friend of mine asked me to host a page for him, and I said that that was possible. Now, he has registered his page (in this example page3456.com) with a registering service. It resolves to my IP (in this example xx.xx.xx.xx). I have put it in the html/page3456 directory.

My page (domain.com) is working fine. Driven to madness I have now tried to also make make my friends'page show in the page3456.domain.com url (that is also registered to resolve to my IP wich it does).

Now, whatever URL we put in any browser, all give my own page. Here is my httpd.conf - PLEASE, tell me what's wrong...


Code:
NameVirtualHost xx.xx.xx.xx

<VirtualHost domain.com>

        ServerAdmin joe@domain.com
        ServerName domain.com
        DocumentRoot /var/www/html
        ServerSignature email
        DirectoryIndex index.php

</VirtualHost>

# Virtual host Virtual Host 1

<VirtualHost page2345.domain.com>

        DocumentRoot /var/www/html/page2345
        ServerAdmin joe@domain.com
        ServerName page2345.domain.com
        ServerSignature email
        DirectoryIndex index.html

	 <Directory "/var/www/html/page2345">
                AllowOverride all
                Allow from from all
                Deny from from all
                Order Deny,Allow
        </Directory>

</VirtualHost>


# Virtual host Virtual Host 2

<VirtualHost xx.xx.xx.xx>

        DocumentRoot /var/www/html/page2345
        ServerName page2345.com
        ServerSignature email

	 <Directory "/var/www/html/page2345">
                AllowOverride all
                Allow from from all
                Deny from from all
                Order Deny,Allow
        </Directory>


</VirtualHost>
The names have been changed to protect te noob...

Last edited by xtra; 08-12-2004 at 05:13 PM.
 
Old 08-12-2004, 10:00 PM   #2
jhayden
LQ Newbie
 
Registered: Mar 2003
Location: Wichita, KS, USA
Distribution: Redhat-7.2,9 Slackware-9.1,10
Posts: 13

Rep: Reputation: 0
Are you trying to use named based (multiple hosts, 1 ip) or ip based (1 ip per host) virtual hosting? If you only have 1 IP address, you'll need to use name based. Please refer to the apache manual. http://httpd.apache.org/docs-2.0/vhosts/name-based.html

If you're using name based, your config would look something like this:
Code:
NameVirtualHost * # Bind to any IP address. Each virtual host declaration should match this.

<VirtualHost *>

        ServerAdmin joe@domain.com
        ServerName domain.com
        DocumentRoot /var/www/html
        ServerSignature email
        DirectoryIndex index.php

</VirtualHost>

<VirtualHost *>

        DocumentRoot /var/www/html/page2345
        ServerName page2345.com
        ServerAlias *.page2345.com
        ServerSignature email

	 <Directory "/var/www/html/page2345">
                AllowOverride all
                Allow from from all
                Deny from from all
                Order Deny,Allow
        </Directory>

</VirtualHost>
I'd recommend using the ServerAlias directive, so page2345.com as well as www.page2345.com and anythingelse.page2345.com will get mapped to your friend's virtual host (assuming it's in the DNS that way). With name-based virtual hosting, whatever you type into your browser (HOST header) will be matched against the ServerName and ServerAlias directives. Remember, if none of the VirtualHosts match, it will default to the first one defined (domain.com in this example.)

Josh

Last edited by jhayden; 08-12-2004 at 10:02 PM.
 
Old 08-18-2004, 07:30 AM   #3
xtra
LQ Newbie
 
Registered: Jun 2004
Posts: 20

Original Poster
Rep: Reputation: 0
Thank you!

I must say the serveralias rule did it! That was the one thing that fixed it. For some reason, if you call the pages seperately it does not work, must be the dns thingy you mentioned.

ALso I had to call the NameVirtualHost to *:80 or httpd would throw up a port 443 error (wich is OK since I have some server running there as well).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 1.3.33 and subdomain fai Linux - Software 1 07-15-2005 03:49 AM
subdomain and apache ziggie216 Linux - Newbie 1 11-12-2003 02:36 PM
Domain and subdomain macadam Linux - Newbie 2 09-18-2003 04:00 PM
how to setup subdomain for users in apache? earl Linux - Security 5 12-05-2002 07:49 AM
Subdomain and apache! eXor Linux - Networking 1 10-13-2002 05:49 PM


All times are GMT -5. The time now is 10:08 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration