View Full Version : Setting up multiple Virtual Hosts
X96 Web Design
05-04-2009, 11:53 PM
I have Apache2 installed - and I can access LocalHost fine, But I want multiple "localhosts".
I think it's called a "virtual host". I don't have/want a domain, just a local server. So if I go to http://someserver/ it'll load like if I put in http://localhost/.
I've looked into it, and all the articles I read either I didn't get, or didn't work...
Anyone help?
I'm pretty comfortable with terminal (GNOME) if anything is needed to be done in terminal
Thanks,
X96 WD
Master_script_maker
05-05-2009, 12:38 AM
maybe http://ubuntuforums.org/showthread.php?t=126298 or http://www.google.com/search?q=multiple+localhosts&btnG=Google+Search ? It involves editing apache/conf/extra/httpd-vhosts.conf . you also have to uncomment a line in httpd.conf from:
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf to
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
X96 Web Design
05-05-2009, 01:12 AM
I;m following this: http://httpd.apache.org/docs/1.3/vhosts/name-based.html, but can't get it to work. Apache isn't giving me errors, but it won't work. I've added the following into httpd.conf:
NameVirtualHost *
<VirtualHost *>
ServerName main-server
DocumentRoot /home/user/public_html
</VirtualHost>
<VirtualHost *>
ServerName x96design
DocumentRoot /home/user/Documents/WebDesign/x96webdesign
</VirtualHost>
I can access http://localhost, but none of the extra virtual hosts I specified in the httpd.conf file.
Any suggestions?
// X \\
Master_script_maker
05-05-2009, 01:18 AM
here is what i have been using:
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost> and you would just change what you need
X96 Web Design
05-05-2009, 02:03 AM
It works perfectly for one location, but what do you have to do in order for the second one to work? How do I assign the second Document Root a different server name? Because no matter what name I put in, it won't work (even after restarting apache)...
I guess I could just change the config file every time I wanted to test a different site (change the document root)
// X96 \\
thetestingsite
05-05-2009, 02:11 AM
If you are doing this locally, you need to have a DNS server local as well to process the domain requests. Otherwise, each host pointing to your server ip will appear as though you typed in localhost.
Hope this helps.
X96 Web Design
05-05-2009, 02:28 AM
So how do I set up a DNS server? :D
// X \\
thetestingsite
05-05-2009, 02:58 AM
it depends. If you have a linux box, you could use "Bind"; or if you have a Windows Server (Win 2k - 2k8) you could use the built in DNS. If you have windows XP or later (not sure about before XP), you may be able to edit your hosts file (\Windows\system32\drivers\etc\hosts) to insert an entry to point to that domain; however, I really don't have a lot of experience with this. The following link may help you further though:
http://vlaurie.com/computers2/Articles/hosts.htm
Hope this helps.
X96 Web Design
05-05-2009, 03:02 AM
I'm using a Linux box, Ubuntu 9.04 to be precise... I'll look into Bind...
I think I'll stick with just one Domain for now... I'll look into it again once I learn a bit more about all this DNS and stuff.
// X \\
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.