virtual hosting

This is a discussion on virtual hosting within the Linux Web Servers forums, part of the Web Server and Related Forums category; Hi I'm quite new to Linux so if some of my questions seem funny, then laugh, but please help ! ;-) ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-24-2003
gilbert labelle
 
Posts: n/a
Default virtual hosting

Hi

I'm quite new to Linux so if some of my questions seem funny, then laugh,
but please help ! ;-)

I installed RH9-Apache2 in it's own box.

I've set virtual hosts, to work locally, like this one :

<virtualhost 127.0.0.1>
documentroot /var/www/html/www.site1.com/www
servername www.site1.com
</virtualhost>

When it's called from Mozilla, (http://localhost/www.site1.com) it opens the
/var/www/html/www.site1.com directory instead of going to the documentroot
and showing the index page.

Why ?

(tried to add a slash at the end of documentroot but it's useless)






  #2 (permalink)  
Old 10-25-2003
David Efflandt
 
Posts: n/a
Default Re: virtual hosting

On Fri, 24 Oct 2003 14:51:59 -0400, gilbert labelle <email@cache.com> wrote:
> Hi
>
> I'm quite new to Linux so if some of my questions seem funny, then laugh,
> but please help ! ;-)
>
> I installed RH9-Apache2 in it's own box.
>
> I've set virtual hosts, to work locally, like this one :
>
><virtualhost 127.0.0.1>
> documentroot /var/www/html/www.site1.com/www
> servername www.site1.com
></virtualhost>
>
> When it's called from Mozilla, (http://localhost/www.site1.com) it opens the
> /var/www/html/www.site1.com directory instead of going to the documentroot
> and showing the index page.
>
> Why ?


Why would you expect http://localhost/ to go to a virtual host that ONLY
has servername www.site1.com. If you want localhost to go to your vhost,
try adding the following to the section for that vhost:

ServerAlias localhost

You can also use any other 127.x.x.x IP for practicing with virtual
hosting (except 127.0.0.0 or 127.255.255.255) if you do not have some
other local net interface.

--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
  #3 (permalink)  
Old 10-25-2003
gilbert labelle
 
Posts: n/a
Default Re: virtual hosting

Thanks for you answer David,

I added the serveralias directive in the vhost section but it leads to
nothing more than before.

RH9 had been installed again as a server with no firewall.

The box has a functionnal cablemodem connexion to Inet but for now I
deactivated it. I also stopped the SSL service to make sure nothing blocks
anything. But when Apache gets to work I want to use the *nix box to connect
the two other Win boxes to Inet. Right now there is no other nic but the one
to the modem in the box.

I reproduced a part of my httpd.conf file.

------------
Listen 80
ServerAdmin root@localhost
ServerName Central
DocumentRoot "/var/www/html"
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot /var/www/html/www.site1.com/www
ServerName www.site1.com
ServerAlias localhost
</VirtualHost>
--------------

At the very beginning I had
NameVirtualHost *
<VirtualHost *>
DocumentRoot /var/www/html/www.site1.com/www
ServerName www.site1.com
</VirtualHost>

but It didn't work, got the same old error msg.


If I type http://www.site1.com in Mozilla I recieve the "www.site1.com could
not be found" message.

I read the Apache's vhost doc and all I can find pertaining to that but
nothing seems to work. Yet it seem so simple for anyone I talked to.

I want to be able to write a simple link in a page in the style of "<A
Href:"www.afakesite.com"></A>" and be sure that the link works what I can't
do right now since I must write the whole path as the argument to href in
order to connect to another fake site on my machine.

I want to learn php, mysql, perl and so on in the closest to real
environment but I can't have that native (Apache) work properly. I begin to
suspect a faulty RH package which I downloaded from a dl site.



"David Efflandt" <efflandt@xnet.com> a écrit dans le message de
news:slrnbpjbt4.ibk.efflandt@typhoon.xnet.com...
> Why would you expect http://localhost/ to go to a virtual host that ONLY
> has servername www.site1.com. If you want localhost to go to your vhost,
> try adding the following to the section for that vhost:
>
> ServerAlias localhost
>
> You can also use any other 127.x.x.x IP for practicing with virtual
> hosting (except 127.0.0.0 or 127.255.255.255) if you do not have some
> other local net interface.



  #4 (permalink)  
Old 10-25-2003
David Efflandt
 
Posts: n/a
Default Re: virtual hosting

On Sat, 25 Oct 2003 10:14:52 -0400, gilbert labelle <email@cache.com> wrote:
> Thanks for you answer David,
>
> I added the serveralias directive in the vhost section but it leads to
> nothing more than before.
>
> RH9 had been installed again as a server with no firewall.
>
> The box has a functionnal cablemodem connexion to Inet but for now I
> deactivated it. I also stopped the SSL service to make sure nothing blocks
> anything. But when Apache gets to work I want to use the *nix box to connect
> the two other Win boxes to Inet. Right now there is no other nic but the one
> to the modem in the box.
>
> I reproduced a part of my httpd.conf file.
>
> ------------
> Listen 80
> ServerAdmin root@localhost
> ServerName Central
> DocumentRoot "/var/www/html"
> NameVirtualHost 127.0.0.1
><VirtualHost 127.0.0.1>
> DocumentRoot /var/www/html/www.site1.com/www
> ServerName www.site1.com
> ServerAlias localhost
></VirtualHost>
> --------------
>
> At the very beginning I had
> NameVirtualHost *
><VirtualHost *>
> DocumentRoot /var/www/html/www.site1.com/www
> ServerName www.site1.com
></VirtualHost>
>
> but It didn't work, got the same old error msg.
>
>
> If I type http://www.site1.com in Mozilla I recieve the "www.site1.com could
> not be found" message.


www.site1.com may not resolve if offline, but if online would point to a
207.218... IP (which is not your IP). If you are going to experiment with
fake names, make sure they could not possibly be real (avoid using 2 or 3
letters after last dot).

Then you need to point your fake names at IPs with either /etc/hosts (see
man hosts) or local DNS (see DNS HOWTO). It is best not to tamper with
the 127.0.0.1 line in /etc/hosts, although, some add hostname or other
names as space separated list of aliases at tnd of that line. Or once you
get your LAN nic up, list them as names for your LAN IP (adjust any "Allow
from" in httpd.conf).

> I read the Apache's vhost doc and all I can find pertaining to that but
> nothing seems to work. Yet it seem so simple for anyone I talked to.
>
> I want to be able to write a simple link in a page in the style of "<A
> Href:"www.afakesite.com"></A>" and be sure that the link works what I can't
> do right now since I must write the whole path as the argument to href in
> order to connect to another fake site on my machine.


I have never noticed ':' used in place of '=' in an href, but any fake
names that you point to loopback IPs will not work beyond the box running
apache. If you want them to work from your LAN, either those boxes
would need your server LAN IP and those names in their hosts file, or you
local DNS configured to resolve them.

> I want to learn php, mysql, perl and so on in the closest to real
> environment but I can't have that native (Apache) work properly. I begin to
> suspect a faulty RH package which I downloaded from a dl site.


Do you have more than 1 apache installed (default from RH CD, and another
one)?

--
David Efflandt - All spam ignored http://www.de-srv.com/
  #5 (permalink)  
Old 10-26-2003
Gilbert Labelle
 
Posts: n/a
Default Re: virtual hosting

Hi Dave,

Here are the last developments based on your advice.

I reproduce some things.

In /etc/hosts

127.0.0.1 localhost.localdomain localhost
192.168.0.100 www.site1.fake


In conf/httpd.conf

Listen 80
ServerName www.central.fake
DocumentRoot "/var/www/html"
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1
DocumentRoot /var/ww/html
ServerName localhost
</VirtualHost>
<VirtualHost 192.168.0.100>
DocumentRoot /var/ww/html/www.site1.com/www
ServerName www.site1.fake
</VirtualHost>

The eth0 device is still not activated and no other NIC has been added to
the box.

Now writing http://www.site1.fake leads to a "The connection was refused
when attempting to contact www.site1.fake" error mesg.

I find it more encouraging than the other message I obtained !! Don't you ??
:-)


> Then you need to point your fake names at IPs with either /etc/hosts (see
> man hosts) or local DNS (see DNS HOWTO). It is best not to tamper with
> the 127.0.0.1 line in /etc/hosts, although, some add hostname or other
> names as space separated list of aliases at tnd of that line. Or once you
> get your LAN nic up, list them as names for your LAN IP (adjust any "Allow
> from" in httpd.conf).
>
> I have never noticed ':' used in place of '=' in an href, but any fake


Sorry it's a typo.

> names that you point to loopback IPs will not work beyond the box running
> apache. If you want them to work from your LAN, either those boxes
> would need your server LAN IP and those names in their hosts file, or you
> local DNS configured to resolve them.


So if I understand well, THE solution to access these fakes by the nix box
keyboard or any other box in a future local lan or internet connection IS
DNS. Right?

> Do you have more than 1 apache installed (default from RH CD, and another
> one)?


I didn't try to install any update or other version. Default from the CD.
And no multiboot. Clean nix box.

Have a good day Dave


  #6 (permalink)  
Old 10-27-2003
Gilbert Labelle
 
Posts: n/a
Default Re: virtual hosting

Hi Dave

I modified hosts and http

Here they are

In /etc/hosts

127.0.0.1 localhost.localdomain localhost
192.168.0.100 www.site1.fake


In conf/httpd.conf

Listen 80
ServerName www.central.fake
DocumentRoot "/var/www/html"
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1
DocumentRoot /var/ww/html
ServerName localhost
</VirtualHost>
<VirtualHost 192.168.0.100>
DocumentRoot /var/ww/html/www.site1.com/www
ServerName www.site1.fake
</VirtualHost>

Now writing http://www.site1.fake leads to a "The connection was refused
when attempting to contact www.site1.fake" error mesg.

I was kind of happy to think that the reason was that the eth0 was still
inactive.

I then enabled eth0 which resulted in a httpd not loaded at boot time, an
error for gnome saying it can lead to eroneous behavior. The prompt in the
terminal has changed from root@localhost to root@x1 00 40 blabla. and I
can't connect to inet anymore.

I understand that to gain maximum flexibility it's better to configure the
DNS.

I'll "play" with that in the next days. After another clean install of RH .

> local DNS configured to resolve them.
>
>
> Do you have more than 1 apache installed (default from RH CD, and another
> one)?
>

No only the default.

Thanks Dave



  #7 (permalink)  
Old 10-27-2003
Gilbert Labelle
 
Posts: n/a
Default Re: virtual hosting

Hi Dave

In the last message I forgot to indicate that before enabling the eth0
device, I tried http://localhost which opened the default test page.

This morning I tried again with no connection to inet, and everything boots
perfectly and acts the same way as before the connection to inet.

So there must be a reason in the inet config for the strange behavior of the
native !!

I'll wait for your answer before doing anything else.

Oh, the result of httpd -D DUMP_VHOSTS gives

----------cut-------------
VirtualHost configuration:
192.168.0.100:* www.site1.fake (/etc/httpd/conf/httpd.conf:863)
wildcard NameVirtualHosts and _default_ servers:
*:* is a NameVirtualHost
default server localhost (/etc/httpd/conf/httpd.conf:857)
port * namevhost localhost (/etc/httpd/conf/httpd.conf:857)
(98)Adresse d!!j!! utilis!!e: make_sock: could not bind to address
0.0.0.0:80
no listening sockets available, shutting down

-----------cut-------------

The line before the last translates to " (98) Address already in use" I
presume. (RH is installed in french).

Thanks for the time you spend with me.


 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:20 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0