Document root not website root

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jpb

    Document root not website root

    Could someone please help me with this.

    I want to use PHP in my website; but run into a snag, the recommended
    method of calling an include is:
    <?php include($_SERVE R["DOCUMENT_R OOT"]."/inc/css-gateway.inc"); ?>

    when I try
    <?php ECHO $_SERVER["DOCUMENT_R OOT"]; ?> the document root is shown as
    /usr/local/apache/htdocs/

    However the website root is at:
    /mnt/home/www/canadian-dream.com/www

    How do I redirect $_SERVER["DOCUMENT_R OOT"] to the my website root? Is
    there a global variable that can be used? I do not wish to rewrite a lot
    of pages if I were to change web host in the future.

    from the error logs

    [Sat Oct 25 06:32:51 2003] [error] PHP Warning:
    main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
    No such file or directory in
    /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15


    [Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
    '/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
    (include_path=' .:/usr/local/lib/php') in
    /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15


    Thanks

    Paul
  • Randell D.

    #2
    Re: Document root not website root


    "jpb" <jpb@arcor.de > wrote in message
    news:pan.2003.1 0.25.10.59.10.7 43551@arcor.de. ..[color=blue]
    > Could someone please help me with this.
    >
    > I want to use PHP in my website; but run into a snag, the recommended
    > method of calling an include is:
    > <?php include($_SERVE R["DOCUMENT_R OOT"]."/inc/css-gateway.inc"); ?>
    >
    > when I try
    > <?php ECHO $_SERVER["DOCUMENT_R OOT"]; ?> the document root is shown as
    > /usr/local/apache/htdocs/
    >
    > However the website root is at:
    > /mnt/home/www/canadian-dream.com/www
    >
    > How do I redirect $_SERVER["DOCUMENT_R OOT"] to the my website root? Is
    > there a global variable that can be used? I do not wish to rewrite a lot
    > of pages if I were to change web host in the future.
    >
    > from the error logs
    >
    > [Sat Oct 25 06:32:51 2003] [error] PHP Warning:
    > main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open stream:
    > No such file or directory in
    > /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
    >
    >
    > [Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
    > '/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
    > (include_path=' .:/usr/local/lib/php') in
    > /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
    >
    >
    > Thanks
    >
    > Paul[/color]

    Have you examined the output of phpinfo();

    You have two different paths noted in your log file - One in
    /usr/local/apache/htdocs, and the other in /mnt/home/www/canadian-dream.com.
    The "/mnt" in one file path leads me to believe you are using NFS, which if
    true, is likely to be part of the problem... If you are using Apache, I know
    it can serve on an NFS server, however I do know there are some issues that
    one must consider when configuring the server - I can't recall what they are
    but maybe that gives you a couple of things to work on... an alternative
    workaround would be to create a variable that has your "include" directory
    hard-coded which you use instead of using "$_SERVER[DOCUMENT_ROOT]" -
    therefore whenever you move the script, you only have to change one
    variable, but I don't really like that sort of idea.

    Hope that gives you some ideas...


    Comment

    • jpb

      #3
      Re: Document root not website root

      On Sun, 26 Oct 2003 06:11:11 +0000, Randell D. wrote:
      [color=blue]
      >
      > "jpb" <jpb@arcor.de > wrote in message
      > news:pan.2003.1 0.25.10.59.10.7 43551@arcor.de. ..[color=green]
      >> Could someone please help me with this.
      >>
      >> I want to use PHP in my website; but run into a snag, the recommended
      >> method of calling an include is:
      >> <?php include($_SERVE R["DOCUMENT_R OOT"]."/inc/css-gateway.inc"); ?>
      >>
      >> when I try
      >> <?php ECHO $_SERVER["DOCUMENT_R OOT"]; ?> the document root is shown as
      >> /usr/local/apache/htdocs/
      >>
      >> However the website root is at:
      >> /mnt/home/www/canadian-dream.com/www
      >>
      >> How do I redirect $_SERVER["DOCUMENT_R OOT"] to the my website root? Is
      >> there a global variable that can be used? I do not wish to rewrite a lot
      >> of pages if I were to change web host in the future.
      >>
      >> from the error logs
      >>
      >> [Sat Oct 25 06:32:51 2003] [error] PHP Warning:
      >> main(/usr/local/apache/htdocs/inc/css-gateway.inc): failed to open
      >> stream: No such file or directory in
      >> /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
      >>
      >>
      >> [Sat Oct 25 06:32:51 2003] [error] PHP Warning: main(): Failed opening
      >> '/usr/local/apache/htdocs/inc/css-gateway.inc' for inclusion
      >> (include_path=' .:/usr/local/lib/php') in
      >> /mnt/home/www/canadian-dream.com/www/de/immobilien/main.php on line 15
      >>
      >>
      >> Thanks
      >>
      >> Paul[/color]
      >
      > Have you examined the output of phpinfo();
      >
      > You have two different paths noted in your log file - One in
      > /usr/local/apache/htdocs, and the other in
      > /mnt/home/www/canadian-dream.com. The "/mnt" in one file path leads me to
      > believe you are using NFS, which if true, is likely to be part of the
      > problem... If you are using Apache, I know it can serve on an NFS server,
      > however I do know there are some issues that one must consider when
      > configuring the server - I can't recall what they are but maybe that gives
      > you a couple of things to work on... an alternative workaround would be to
      > create a variable that has your "include" directory hard-coded which you
      > use instead of using "$_SERVER[DOCUMENT_ROOT]" - therefore whenever you
      > move the script, you only have to change one variable, but I don't really
      > like that sort of idea.
      >
      > Hope that gives you some ideas...[/color]


      I have a work around, not very elligent but works like a Lada

      conf.php

      <?php
      //CONTENT OF THE FILE
      $mydocumentroot =$_SERVER["DOCUMENT_R OOT"];

      if($mydocumentr oot!="/home/jpb/public_html/www")
      {
      $mydocumentroot ="/mnt/home/www/canadian-dream.com/www";
      }
      //END OF THE INCLUDED FILE
      ?>


      on webpage <?php include("../../../etc-etc-/inc-php": ?>
      then use <?php include($mydocu mentroot."bla.i nc") ?>

      Paul


      Comment

      Working...