Virtualhost configuration

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

I'm trying to set up my server so that I can have both my sites on it, pointing to different directories.
What is the virtualhost configuration I should set it to?
I tried adding some, but they didn't work.
Do I need a DNS server on here?
Thanks

Laughing out loud

He has: 1,016 posts

Joined: May 2002

You don't have to run your own DNS server. You could simply use your registrars (if they offer one) or a free service like mydomain.com

Once the domain is pointing to your server, you need to edit your Apache's configuration file and add a new virtualhost directive. You can find more information about this at http://httpd.apache.org/docs/vhosts/index.html

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

I already have DNS
I wanted to know if I needed some sort of DNS to point my domain to my folders.
I'll try that out

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

I'm doing something wrong

NameVirtualHost 68.55.169.109
<VirtualHost <a href="http://www.thenga.com" class="bb-url">thenga.com</a>>
        ServerName <a href="http://www.thenga.com" class="bb-url">thenga.com</a>
        DocumentRoot /web/html/thenga
</VirtualHost>
<VirtualHost <a href="http://www.e-ngl.net" class="bb-url">e-ngl.net</a>>
        ServerName <a href="http://www.e-ngl.net" class="bb-url">e-ngl.net</a>
        DocumentRoot /web/html/engl
</VirtualHost>
'

Why doesn't this work? Should I get rid of my regular DocumentRoot and use only the virtualhost?
Thanks

Laughing out loud

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

NameVirtualHost <a href="http://www.thenga.com" class="bb-url">thenga.com</a>
NameVirtualHost <a href="http://www.e-ngl.net" class="bb-url">e-ngl.net</a>
<VirtualHost <a href="http://www.thenga.com" class="bb-url">thenga.com</a>>
        ServerName <a href="http://www.thenga.com" class="bb-url">thenga.com</a>
        DocumentRoot /web/html/thenga
</VirtualHost>
<VirtualHost <a href="http://www.e-ngl.net" class="bb-url">e-ngl.net</a>>
        ServerName <a href="http://www.e-ngl.net" class="bb-url">e-ngl.net</a>
        DocumentRoot /web/html/engl
</VirtualHost>
'

Mark Hensler
If there is no answer on Google, then there is no question.

He has: 1,016 posts

Joined: May 2002

Assuming your IP is 68.55.169.109, you should have..

NameVirtualHost 68.55.169.109
<VirtualHost 68.55.169.109>
        DocumentRoot /web/html/thenga
        ServerName thenga.com
        ServerAlias <a href="http://www.thenga.com" class="bb-url">thenga.com</a>
</VirtualHost>
<VirtualHost 68.55.169.109>
        DocumentRoot /web/html/engl
        ServerName e-ngl.net
        ServerName <a href="http://www.e-ngl.net" class="bb-url">e-ngl.net</a>
</VirtualHost>
'

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

Tried them both, Mark's and Zollet's... neither worked.
Could there be something else in my httpd.conf file that is messing this up? the other DocumentRoot in it?
Just an idea though

Laughing out loud

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

BindAddress *

He has: 1,016 posts

Joined: May 2002

Yeah, make sure you have the BindAddress line. I just noticed a small error in what I poseted before..

ServerName e-ngl.net
ServerName e-ngl.net

..should be..

ServerName e-ngl.net
ServerAlias e-ngl.net

This is to that your domains work with and without www.

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

Could I also do it with the www or do have to not?

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

Still not working
Both point to /var/www/thenga
Why is one over the other?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

try this..

# ports to listen to
Listen 80

# IPs to listen to
BindAddress *

#...

NameVirtualHost *

<VirtualHost *>
    DocumentRoot /web/html/thenga
    ServerAdmin [email protected]
    ServerName www.thenga.com
</VirtualHost>
<VirtualHost
*>
    DocumentRoot /web/html/engl
    ServerAdmin [email protected]
    ServerName www.e-ngl.net
</VirtualHost>
'That should be enough. Try running `apachectl configtest` and then either `apachectl reload` or`apachectl restart`.

Mark Hensler
If there is no answer on Google, then there is no question.

nike_guy_man's picture

They have: 840 posts

Joined: Sep 2000

OK!
That worked fine for configuration... but it tells me that apachectl is an invalid command... is that a Mandrake thing?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

No, I guess it's a unix thing.
It should be located ~/apache/bin/apachectl

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.