PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > comp.info.servers.unix > apache - incorrect document root reported under dynamic virtual hosts
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.info.servers.unix Web servers for UNIX platforms.

apache - incorrect document root reported under dynamic virtual hosts

Réponse
 
LinkBack Outils de la discussion
Vieux 27/07/2005, 18h48   #1
weiwang168@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut apache - incorrect document root reported under dynamic virtual hosts

I just started to try the Dynamic Virtual Hosts for Apache. All is
good, but when I have a PHP script that relies on
$_SERVER["DOCUMENT_ROOT"] to access some include files, it failed. The
value being reported back is the top Document Root defined in the
Apache conf file, something like '/var/www', instead of the correct
value of '/var/www/domain.com/'.

Does this mean that I cannot rely on the Document Root value when the
site is managed under Dynamic Virtual Host?

Thanks.

Wei

  Réponse avec citation
Vieux 27/07/2005, 22h12   #2
The Doctor
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: apache - incorrect document root reported under dynamic virtual hosts

In article <1122486494.398507.3080@g47g2000cwa.googlegroups.c om>,
<weiwang168@gmail.com> wrote:
>I just started to try the Dynamic Virtual Hosts for Apache. All is
>good, but when I have a PHP script that relies on
>$_SERVER["DOCUMENT_ROOT"] to access some include files, it failed. The
>value being reported back is the top Document Root defined in the
>Apache conf file, something like '/var/www', instead of the correct
>value of '/var/www/domain.com/'.
>
>Does this mean that I cannot rely on the Document Root value when the
>site is managed under Dynamic Virtual Host?
>
>Thanks.
>
>Wei
>


Try declaring your document root

For Example:

<host 10.0.0.1>
....
DocumentRoot /usr/home/user/html
....
</host>

--
Member - Liberal International
This is doctor@nl2k.ab.ca Ici doctor@nl2k.ab.ca
God Queen and country! Beware Anti-Christ rising!
Better to serve in Heaven that to Rule in Hell.
  Réponse avec citation
Vieux 28/07/2005, 01h28   #3
weiwang168@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: apache - incorrect document root reported under dynamic virtual hosts

Thanks. But you did not understand my question. i am using Dynamic
Virtual Host, not the normal virtual host. So what you just said does
not apply.

  Réponse avec citation
Vieux 28/07/2005, 08h27   #4
Mark D Smith
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: apache - incorrect document root reported under dynamic virtual hosts


<weiwang168@gmail.com> wrote in message
news:1122510497.716153.235990@f14g2000cwb.googlegr oups.com...
> Thanks. But you did not understand my question. i am using Dynamic
> Virtual Host, not the normal virtual host. So what you just said does
> not apply.
>


Hi

look up VirtualDocumentRoot at http://httpd.apache.org/

we use

VirtualDocumentRoot /home/domain/users/%2.1/%2.2/%2/web

Mark

  Réponse avec citation
Vieux 28/07/2005, 10h11   #5
Nick Kew
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: apache - incorrect document root reported under dynamic virtualhosts

weiwang168@gmail.com wrote:

> Does this mean that I cannot rely on the Document Root value when the
> site is managed under Dynamic Virtual Host?


If by "dynamic virtual host" you mean some mass-vhosting solution,
then yes.

With normal vhosts, apache keeps information for each host in a separate
object. That includes both simple stuff like document root and more
expensive stuff like file descriptors for the logs. That's great for
a small number of hosts, but doesn't scale well to larger numbers.
So mass-virtual-hosting uses a single server_rec for all vhosts.

--
Nick Kew
  Réponse avec citation
Vieux 28/07/2005, 14h32   #6
weiwang168@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: apache - incorrect document root reported under dynamic virtual hosts

Thanks! But how do you get around it then? Like I said, my PHP script
relies on the $_SERVER["DOCUMENT_ROOT"] value so that it can includes
other files correctly. If under mass vhosting, Apache does not report
that document root anymore, then my script is broken. I hate to go back
and change all the include path to relative, just thinking about all
those "../../../../" is driving me nuts.

Is there any way to have Apache report the correct document root even
using mass vhosting?

Thanks again.

Wei

  Réponse avec citation
Vieux 29/07/2005, 22h31   #7
Jorey Bump
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: apache - incorrect document root reported under dynamic virtual hosts

weiwang168@gmail.com wrote in news:1122557556.927518.15080
@g49g2000cwa.googlegroups.com:

> Thanks! But how do you get around it then? Like I said, my PHP script
> relies on the $_SERVER["DOCUMENT_ROOT"] value so that it can includes
> other files correctly. If under mass vhosting, Apache does not report
> that document root anymore, then my script is broken. I hate to go back
> and change all the include path to relative, just thinking about all
> those "../../../../" is driving me nuts.
>
> Is there any way to have Apache report the correct document root even
> using mass vhosting?


Depending on how you've set up mass virtual hosting, maybe you can
concatenate:

$docroot = $_SERVER["DOCUMENT_ROOT"] . "/" . $_SERVER["SERVER_NAME"]

Adjust to suit your configuration.
  Réponse avec citation
Vieux 30/07/2005, 00h21   #8
weiwang168@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: apache - incorrect document root reported under dynamic virtual hosts

Thanks guys! i guess i cannot rely on Apache any more. i will have to
figure something out. because i also want the script to be portable.
meaning when migrated to other hosting environment that use normal
vhosting, it will still work.

thanks!

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h42.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12033 seconds with 16 queries