Virtual host apache2
Hi,
trying to get a virtualhost working on apache2. The thing being its only on a local network so when it comes to the naming convention i am lost. It seems all the examples show live websites e.g. www.example.com, www.example2.com I am basically trying to use the same ip address on my server called penguin. then i want a second server called something else on the same ip. Seems that people can do this, but i really dont understand all the many examples i have read. Anyone help plz |
If its purely for internal consumption, you can call it anything you like, although you'll need an equiv entry in /etc/hosts so the browser can find it, or a local DNS server.
Personally, like the fact that you should only use private ip ranges for this eg 192.168.x.x I (and others) also create fictitious domain names, so it's obvious if it escapes onto the internet it will get dropped instead of ending up at a real (not yours) website. eg site1.domain.cxm # note cxm is not a valid tld on the web. YMMV If this is for work (even if its only internal), you should get a proper name. |
Hi,
First thing with hosting a virtual host, if you are using multiple different domain names, if I remember right you have to uncomment the following line in the httpd.conf file, I can't remember this for certain if it's this line, there is certainly one line it has to be done but from memory it should look like the following. #NameVirtualHost *:80 Just delete the #, you may possible want to change the listen port if it's not going to be port 80. After this you then you set up your virtual host something like the following substituting the <> for what ever needs to go there Code:
<VirtualHost *:80> |
Quote:
Code:
listen 8010 Code:
http://(name or ip of host):8010 You can create as many such virtual servers as you like, each with a different access port. This method using different access ports is by far the simplest way to create virtual servers, which explains why it's used so often. |
Thanks for that. I will try it.
The other method i cant get my head round, cause even if i had a dns entry for penguin = 10.101.22.254 then had penguin2 = 10.101.22.254 how could that work? Anyhows will try the port thing |
Even though both the VirtualHost containers are using the same IP address (NameBased VirtualHosting), Apache web server checks the Hostname/domain name in the HTTP header and shows the loads/parses the corresponding index page from the respective VirtualHost DocumentRoot.
You can check the following documentation page for better understanding and more information, |
*:8010 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported
Hmm got this error whilst trying to restart apache. I am thinking the other server instances need ports fixing rather than using any? |
have you read the apache docs for this .i found them VERY helpful 6 years ago when i set up my first server
and still do use them . http://httpd.apache.org/docs/2.2/vhosts/ |
Ye I read that page. Not very useful good really.
Am getting somewhere. I use the port mapping idea but the thing being it takes me to the same document root as the original server. I have changed the documentroot on the virtual host... but not getting that htdocs folder content. tut |
Ok got it.
Had to remove the default entries in sites-enabled and sites-available for my VirtualHost to work Err actually DONT delete these files. I had a bit of an issue since doing so. Give me a moment |
If you ever decide to use a control panel for ease admin and user use. You can install webmin and virtuemin. Just a suggestion.
|
It seems that webmin was creating files in sites-available but missing top line
<VirtualHost *:80> etc etc needed NameVirtualHost *:80 <VirtualHost *:80> etc etc |
That's why I mentioned that darned line before, nothing more fun then having to hunt through documents just to find you need that line uncommented and active! Gotta love reading all the way through such a large file as the httpd.conf
|
All times are GMT -5. The time now is 08:39 PM. |