LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-12-2006, 06:40 PM   #1
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Rep: Reputation: 30
Apache: virtual host issue


I have a server I pay for, and one I run. My biyg.org points to the server I pay for. I want fwarlords.biyg.org (and only that) to point to a certain folder (fwarlords) on the server I run. Here is what I have in the httpd.conf:

Code:
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/fwarlords"
ServerName fwarlords.biyg.org
<Directory "/opt/lampp/htdocs/fwarlords">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
But it's wrong. If you go to zeno.biyg.org which should point to the server I run (the index site) it still points to the fwarlords folder for some reason. How can I fix this?
 
Old 12-12-2006, 10:47 PM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
My understanding of apache:
It looks in the virtualhost section for the servername (fwarlords......).
Next it takes the associated document root and looks in there for the pages. And the associated document root refers to the system where apache is running (so the server that you pay for).

I might, however, be totally wrong.

The only way I see is that you mount the directory of your own server on the server that you pay for. Wonder if your hosting provider allows this.
As an alternative, you can create an index page on the server that you pay for and let that redirect the visitor to the site on your own server; this is however not as neat.
 
Old 12-12-2006, 11:28 PM   #3
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
I'm pretty sure it can be done, there are examples I seem to have seen but can't remember offhand at this time. Oh and I forgot to mention, the domain (biyg.org) is set to the nameserver of my paid server. That's what I mean by "pointing to the server I pay for".
 
Old 12-13-2006, 01:13 AM   #4
mrJimmbo
LQ Newbie
 
Registered: Dec 2006
Location: Australia
Distribution: Fedora Core
Posts: 9

Rep: Reputation: 0
Could it be the zone records in the name server that hosts the domain biyg.org?

If the name server doesn't know where to direct the subdomain to there could be problems...
 
Old 12-13-2006, 11:58 AM   #5
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
You're telling me I have to talk to my paid hosting server every time I want to make a new subdomain (that I own) that points to my own server?
 
Old 12-13-2006, 12:10 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Remember, from your main server configuration in httpd.conf, when creating a VirtualHost, you'll also need a configuration for your main domain, when creating a subdomain.

Make you're original look like this:

Code:
NameVirtualHost *:80

<VirtualHost *>
  DocumentRoot "/opt/lampp/htdocs/"
  ServerName biyg.org
  ServerAlias *.biyg.org
    <Directory "/opt/lampp/htdocs/fwarlords">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>

<VirtualHost *>
  DocumentRoot "/opt/lampp/htdocs/fwarlords"
  ServerName fwarlords.biyg.org
    <Directory "/opt/lampp/htdocs/fwarlords">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>
Make the necessary changes for actual file paths but it should look something like that. And you don't necessarily need to specify the port in the VirtualHost tag if the default is already 80. And you might not need the <Directory> tags for your main domain of biyg.org either, but like I said, mine is just an example of what should work.

Plus after making changes, you need to restart apache for the configs to be reread. You can run a configtest to test the configuration before restarting to prevent any failures if the configs won't work and then your site is unaccessible.
 
Old 12-13-2006, 05:33 PM   #7
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
That looks right (the paths), so here's what I put in:
Code:
NameVirtualHost *:80

<VirtualHost *>
  DocumentRoot "/opt/lampp/htdocs/"
  ServerName biyg.org
  ServerAlias *.biyg.org
</VirtualHost>  

<VirtualHost *>
  DocumentRoot "/opt/lampp/htdocs/fwarlords"
  ServerName fwarlords.biyg.org
    <Directory "/opt/lampp/htdocs/fwarlords">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>
I get this warning on restarting Apache:
Quote:
[Wed Dec 13 19:24:27 2006] [warn] NameVirtualHost *:80 has no VirtualHosts
But now if you go to fwarlords.biyg.org or zeno.biyg.org, both point to the index. Fwarlords should bring you to the fwarlords folder, but no longer does.
 
Old 12-13-2006, 05:51 PM   #8
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
What version of Apache are you running? Try adding the *:80 in the <VirtualHost> tags for each VirtualHost.
 
Old 12-13-2006, 05:53 PM   #9
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
I just tested both of these domains and they both seem to resolve to different pages. From this end I would assume they are working.
 
Old 12-13-2006, 06:50 PM   #10
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Really? zeno.biyg.org takes you to a different page than fwarlords.biyg.org? It doesn't for me. I just talked to a friend, he also says both pages take him to the same page (which is wrong).

Apache version 1.3.33, adding that :80 part fixes the warning but not the sites.

Last edited by Zeno McDohl; 12-13-2006 at 06:51 PM.
 
Old 12-13-2006, 09:10 PM   #11
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by Zeno McDohl
Really? zeno.biyg.org takes you to a different page than fwarlords.biyg.org? It doesn't for me. I just talked to a friend, he also says both pages take him to the same page (which is wrong).

Apache version 1.3.33, adding that :80 part fixes the warning but not the sites.
Oh wait. I tested fwarlords.biyg.org and just biyg.org, which take you to different pages. If you need zeno.biyg.org to go to a different page, you have to also create a VirtualHost for it as well.
 
Old 12-13-2006, 09:36 PM   #12
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Oh, okay. Because biyg.org has nothing to do with what we're doing here.

But uh... zeno.biyg.org goes to the right page, fwarlords.biyg.org does not. Even though I already have a VirtualHost (like you told me to do) for that. Right now fwarlords.biyg.org points to /opt/lampp/htdocs/ instead of /opt/lampp/htdocs/fwarlords
 
Old 12-16-2006, 10:07 PM   #13
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
I might not be clear, since there seems to be some misunderstanding.

ServerA: A webserver host I am paying for.
ServerB: My own server (located in my room).
Domain: I own the biyg.org domain. The domain uses ServerA's nameserver.

Both fwarlords.biyg.org and zeno.biyg.org need to point to ServerB. Which they do. fwarlords.biyg.org needs to point to /opt/lampp/htdocs/fwarlords on ServerB, while zeno.biyg.org needs to point to /opt/lampp/htdocs/ on ServerB. wwww.biyg.org has nothing to do with this.

With this:
Code:
NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot "/opt/lampp/htdocs/"
  ServerName biyg.org
  ServerAlias *.biyg.org
</VirtualHost>  

<VirtualHost *:80>
  DocumentRoot "/opt/lampp/htdocs/fwarlords"
  ServerName fwarlords.biyg.org
    <Directory "/opt/lampp/htdocs/fwarlords">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>
It doesn't fully work. Both zeno.biyg.org and fwarlords.biyg.org both point to /opt/lampp/htdocs/fwarlords on ServerB.
 
Old 12-19-2006, 03:57 PM   #14
s1m.com
LQ Newbie
 
Registered: Dec 2006
Posts: 1

Rep: Reputation: 0
mrJimmbo has identified your problem. Requests for biyg.org go to the server at your paid hosting service. The DNS server there needs to know where to direct subdomain requests. This is ususally done by adding a "A" record.
 
Old 12-19-2006, 09:34 PM   #15
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
I already have A records for both subdomains, they both point to ServerB's IP. Is that correct?
 
  


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
Virtual Host issue with apache gauge73 Linux - Networking 1 07-12-2005 02:00 PM
Apache Virtual Host problem - DNS or DHCP issue? costrevs Linux - Software 16 03-23-2005 07:50 AM
Apache 2 Virtual host eckertc1 Linux - Software 6 03-22-2005 09:58 PM
Apache 2.0 Virtual Host? w0lfeyes Linux - Networking 1 05-03-2004 03:09 PM
Virtual Host Redirect Issue DigiDave Linux - Software 1 10-23-2003 01:40 PM

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

All times are GMT -5. The time now is 03:59 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