httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ondřej Surý <ond...@sury.org>
Subject Re: SetVirtualDocumentRoot / per request document root / context root?
Date Mon, 20 Dec 2010 09:25:15 GMT
On Mon, Dec 20, 2010 at 00:27, Stefan Fritsch <sf@sfritsch.de> wrote:
> On Monday 13 December 2010, William A. Rowe Jr. wrote:
>> On 12/13/2010 4:35 AM, Stefan Fritsch wrote:
>> > On Monday 13 December 2010, Ondřej Surý wrote:
>> >> On Mon, Dec 13, 2010 at 04:15, William A. Rowe Jr. <wrowe@rowe-
>> >
>> > clan.net> wrote:
>> >>> On 12/12/2010 4:23 PM, Stefan Fritsch wrote:
>> >>>> On Wednesday 10 November 2010, Stefan Fritsch wrote:
>> >>>>>> The frequency with which this gets asked seems to make it
>> >>>>>> worthwhile doing something, even if this patch isn't the
>> >>>>>> right thing to do.
>> >>>>>
>> >>>>> Maybe the larger solution of having a document_root field in
>> >>>>> the request_rec would be better. Has anyone had a chance to
>> >>>>> look at Ondrej's patch, already? I didn't get around to doing
>> >>>>> it, yet.
>> >>>>>
>> >>>>> https://issues.apache.org/bugzilla/show_bug.cgi?id=49705
>> >>>>
>> >>>> I have looked at the patch and it looks reasonable. The fact
>> >>>> that two known modules (mod_vhost_ldap and mod_ftp) copy the
>> >>>> whole server_rec just to change the document root means that
>> >>>> this feature is needed.
>> >>>>
>> >>>> Well, at least for mod_ftp it is...
>> >>>>
>> >>>> I am wondering if the people who want this for mod_vhost_*
>> >>>> actually want something else, namely an easy way to get the
>> >>>> root dir of a web application in php/cgi/whatever...
>> >>>>
>> >>>> What about this idea:
>> >>>>
>> >>>> Add two new cgi env variables: CONTEXT_ROOT and
>> >>>> CONTEXT_ROOT_PATH (or APP_ROOT/APP_ROOT_PATH or ...). And add
>> >>>> a new config directive
>> >>>
>> >>> Feh... DOCUMENT_ROOT was bad enough, do we have to persist the
>> >>> concept of sharing such things with the app?  For that matter,
>> >>> what are the vars that are used in app doc models today, why
>> >>> would we have to invent this again?
>> >
>> > These things are handled nicely in the JEE world by AJP and the
>> > servlet container. They don't seem to work all that well in the
>> > CGI-/PHP-world.
>>
>> So before inventing semantics, pointers to the Servlet semantics
>> and/or the ASP.NET semantics would be appropriate, and discuss an
>> established model and naming conventions you've already identified
>> as working nicely. No?
>
> JEE has the notion of a servlet context which has a context root path.
> Servlets only need to know paths relative to the context root and can
> use the methods getRealPath() to convert it into a file system path
> and getResource() to convert it into an URI. [1]
>
> This does of course not map directly to CGI scripts. But my idea was
> that the script only knows the path relative to the context root and
> then prepends the variables CONTEXT_ROOT or CONTEXT_ROOT_PATH to get a
> URI or file system path, respectively. Maybe CONTEXT_ROOT should be
> named CONTEXT_ROOT_URI instead.
>
> I really think having two such variables always defined to the correct
> values (even with mod_alias/mod_userdir/ssl-offload/...) would be a
> good thing, even if it takes a few years until they get adopted by web
> applications.

Stefan, it doesn't have to take a long time. If you are willing to
backport the patch to next stable Debian (or if this gets enough
attention and it will get adopted to 2.4 and next stable will have
2.4), we can adopt it for PHP5 as soon as this hits the unstable.

I would be more then happy to do such work and modify my patch to not
touch DOCUMENT_ROOT, but create new per-request CONTEXT_ROOT. E.g. if
we can agree how to proceed I am willing to throw my hands on such
code.

Ondrej
-- 
Ondřej Surý <ondrej@sury.org>

Mime
View raw message