|
|
|
|
||||||
| comp.info.servers.unix Web servers for UNIX platforms. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
<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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
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! |
|
![]() |
| Outils de la discussion | |
|
|