Forum Moderators: phranque

Message Too Old, No Replies

Trouble w/ $_SERVER['DOCUMENT_ROOT']

local and remote server compatiblity

         

Storyman

8:47 pm on Nov 21, 2004 (gmt 0)

10+ Year Member



The PHP command $_SERVER['DOCUMENT_ROOT'] works fine on the remote server. The problem is with the local testing server.

The C: drive has a root directory "websites" and beneath that folder are the names of various web sites.
I.E. the path for the index.html in the mysite website looks like this:
C:/websites/mysite/public_html/index.html

When $_SERVER['DOCUMENT_ROOT'] is used on the local testing server it comes back with:
C:/websites

When the same command is used on the remote server the results show the complete path--so everything is fine there.

I've added the directory in Apache, but the results are the same.

What needs to be adjusted so that $_SERVER['DOCUMENT_ROOT'] will provide the full path as it does on the remote server? Since there are several web site folders beneath the directory "websites" it is important that the result returned be to current site giving the request for $_SERVER['DOCUMENT_ROOT'].

jdMorgan

9:08 pm on Nov 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To clarify:

> I've added the directory in Apache, but the results are the same.

You have added the Apache DocumentRoot directive defining the full path within the server definition in httpd.conf?

Jim

Storyman

12:40 am on Nov 22, 2004 (gmt 0)

10+ Year Member



Jim,

Sorry if I'm not clear.

The httpd.conf file had the following (it has since been remarked out):

#<Directory "C:/websites/mysite/public_html">
# Options FollowSymLinks Indexes MultiViews
# Allow from All
# Order Allow,Deny
# AllowOverride None
#</Directory>

Just in case the conf for websites has a bearing on this I'm including it:

<Directory "C:/websites">
Options FollowSymLinks Indexes MultiViews
Allow from All
Order Allow,Deny
AllowOverride All None FileInfo AuthConfig Limit Indexes Limit Options
AddHandler server-parsed .shtml
</Directory>

Working with the server is about as clear to me as a London Fog.

Whatever change is made it is important that it apply to several different websites (mysite1, mysite2, mysite3, etc.)

jdMorgan

1:56 pm on Nov 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is usual to declare each "site" as a separate virtual host under Apache. For each virtual host, you set up a <VirtualHost> container in httpd.conf that "associates" various data pertaining to that host. Among them is the DocumentRoot for that virtual server.

Take a look at the Apache document Dynamically configured mass virtual hosting [httpd.apache.org]. I'm not proposing that you actually set up a development server this way (using dynamic vhosts has drawbacks, especially the log-file problem described), but rather, take a look at their first configuration example that shows the non-dynamic virtual host setup. There, you can see the DocumentRoot associated with the ServerName and ScriptAlias.

Jim