questions about document_root

2011-12-07 Thread Rui Hu
Hi,
I want to modify apache core to implement a function which can achieve
following expectations:

when I request 1000.xxx.com/test.php ( curl 1000.xxx.com/test.php),
originally apache will get absolute address as $document_root/test.php, but
I want apache to get "$document_root/1000/test.php". Namely, apache will
parse "1000" from the request URI to form absolute address. Then php-cgi
can get this php script to execute.

Previously, I just modified PHP zend to achieve this function. But
considering that other language support would be added to the system such
as Python, therefore, modifying Web Server (apache) is a more convenient
way.

But I'm worried that this modification will result in some unexpected
errors in some modules, and I don't know what's the best place I should
modify. Should I modify the $document_root or $request_uri ?

Really appreciate your help.


-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


Re: questions about document_root

2011-12-07 Thread Rui Hu
Thanks for you advice. I just started to learn Apache & PHP.

I looked up the code of PHP and apache2, and found that PHP gets docroot
from environment var "$DOCUMENT_ROOT". However in apache, I cannot find any
code which assign this var.

I googled but got nothing. Can you please show me the detailed process
generating $DOCUMENT_ROOT in $_SERVER from apache to php. Thank you very
much!



2011/12/7 Nick Kew 

>
> On 7 Dec 2011, at 10:54, Rui Hu wrote:
>
> > Hi,
> > I want to modify apache core to implement a function which can achieve
> following expectations:
>
> That's a simple task for a simple module.
>
> Since you talk of modifying the core, I infer you're not familiar with the
> modular structure.
> If I might indulge in a bit of self-promotion, a startingpoint for this is
> ISBN: 0-13-240967-4
> (also http://www.apachetutor.org/ )
>
> --
> Nick Kew




-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


Re: questions about document_root

2011-12-07 Thread Rui Hu
2011/12/8 Rui Hu 

> Is $DOCUMENT_ROOT in php-cgi determined by ap_add_common_vars() in Apache?
> It seems not to me. I commented the line 237 assigning DOCUMENT_ROOT and
> re-compiled apache. php-cgi still works fine. It seems that $DUCUMENT_ROOT
> in php-cgi is not determined by this function.
>
> I looked up php's code, php-cgi gets DOCUMENT_ROOT in following codes:
>
> /* DOCUMENT_ROOT */
> value = lstFset_get(rc->t->vars, "docroot");
> if (value != NULL)
>   php_register_variable("DOCUMENT_ROOT", value, track_vars_array
> TSRMLS_CC);
>
> It gets docroot from a k-v table and the key is "docroot". In above code,
> rc->t is a  variables of httpTtrans.
>
>
> 2011/12/8 Mark Montague 
>
>> On December 7, 2011 23:23 , Rui Hu  wrote:
>>
>>> I looked up the code of PHP and apache2, and found that PHP gets docroot
>>> from environment var "$DOCUMENT_ROOT". However in apache, I cannot find any
>>> code which assign this var.
>>>
>>> I googled but got nothing. Can you please show me the detailed process
>>> generating $DOCUMENT_ROOT in $_SERVER from apache to php. Thank you very
>>> much!
>>>
>>
>> If you invoke PHP as a CGI, then Apache HTTP Server sets DOCUMENT_ROOT in
>> the function ap_add_common_vars() which is in the file server/util_script.c
>>
>> See line 237,
>>
>> https://svn.apache.org/viewvc/**httpd/httpd/branches/2.2.x/**
>> server/util_script.c?revision=**1100216&view=markup<https://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/server/util_script.c?revision=1100216&view=markup>
>>
>>
>> --
>>  Mark Montague
>>  m...@catseye.org
>>
>>
>
>
> --
> Best regards,
>
> Rui Hu
>
> --------
> State Key Laboratory of Networking & Switching Technology
> Beijing University of Posts and Telecommunications(BUPT)
> MSN: tchrb...@gmail.com
>
> -
>
>
>


-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


questions about rewrite module

2011-12-19 Thread Rui Hu
hi,

I encountered a problem while configured virtual host. My experiment
environment is Apache2+fastcgi+php-cgi.

I want to implement mass virtual hosting using rewrite rules based on
apache rewrite module. That is, for a request url like:
http://1000.xyz.com/test.php, apache will translate it to a absolute file
path like: $DOCUMENT_ROOT/1000/test.php, and then get this script to
execute.

And my conf is:
*RewriteEngine On*
*RewriteCond "%{HTTP_HOST}" "!^www.xyz.com"*
*RewriteCond "%{HTTP_HOST}" "^([^.]+)\.xyz\.com" [NC]*
*RewriteRule "(.*)" "/%1$1" [PT]*
I use inner redirection in order not to expose this detail to users.
Besides, I succeeded when I use external redirection, namely the [R] tag
instead of [PT] tag.
When I use [PT] tag, apache cannot run expectedly. I request a url :
http://1000.xyz.com/test.php, error message pops out like: The requested
URL /1000/cgi-bin/php.fcgi/1000/test.php was not found on this server.

I don't know if this error results from fastcgi, is it the inappropriate
config in fastcgi or inevitable problem by using it?

Really appreciate your help.

Vic

-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


Re: questions about rewrite module

2011-12-26 Thread Rui Hu
Thanks for your response. Actually I considered mod_vhost_alias and it
worked well.

I just wanted to try some different ways, and wondered why mod_rewrite
cannot work well with fastcgi. I assume that mod_rewrite is more flexible
in url redirecting than mod_vhost_alias, and I can implement some url
redirecting of more complexity based on this module. That's why I eager to
solve this problem :-).

2011/12/26 Igor Galić 

>
>
> - Original Message -
> > hi,
>
> Hi,
>
> Questions about how to *use* mod_rewrite -- or any module -- are
> best asked on users@
>
> > I encountered a problem while configured virtual host. My experiment
> > environment is Apache2+fastcgi+php-cgi.
> >
> >
> > I want to implement mass virtual hosting using rewrite rules based on
> > apache rewrite module. That is, for a request url like:
> > http://1000.xyz.com/test.php , apache will translate it to a
> > absolute file path like: $DOCUMENT_ROOT/1000/test.php, and then get
> > this script to execute.
>
> Have you considered using something like mod_vhost_alias?
>
>  http://httpd.apache.org/docs/current/mod/mod_vhost_alias.html
>  http://wiki.apache.org/httpd/VirtualHostAlias
>
> > And my conf is:
> >
> > RewriteEngine On
> > RewriteCond "%{HTTP_HOST}" "!^ www.xyz.com "
> > RewriteCond "%{HTTP_HOST}" "^([^.]+)\.xyz\.com" [NC]
> > RewriteRule "(.*)" "/%1$1" [PT]
> >
> > I use inner redirection in order not to expose this detail to users.
> > Besides, I succeeded when I use external redirection, namely the [R]
> > tag instead of [PT] tag.
> > When I use [PT] tag, apache cannot run expectedly. I request a url :
> > http://1000.xyz.com/test.php , error message pops out like: The
> > requested URL /1000/cgi-bin/php.fcgi/1000/test.php was not found on
> > this server.
> >
> >
> > I don't know if this error results from fastcgi, is it the
> > inappropriate config in fastcgi or inevitable problem by using it?
> >
> >
> > Really appreciate your help.
> >
> >
> > Vic
> >
> > --
> > Best regards,
> >
> > Rui Hu
> >
> 
> > State Key Laboratory of Networking & Switching Technology
> > Beijing University of Posts and Telecommunications(BUPT)
> > MSN: tchrb...@gmail.com
> >
> -
> >
> >
> >
>
> --
> Igor Galić
>
> Tel: +43 (0) 664 886 22 883
> Mail: i.ga...@brainsware.org
> URL: http://brainsware.org/
> GPG: 6880 4155 74BD FD7C B515  2EA5 4B1D 9E08 A097 C9AE
>



-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


one problem processing config file

2012-02-22 Thread Rui Hu
hi,

I want to develop a module, which can implement simple function for each
root directory like 1) set error document, 2) set default page, 3) simple
url rewrite rules.

In this function, I can design my own directive and rewrite rule
expressions. But I not sure if those functionalities can be implemented in
one module, should I also modified Apache core?

Thanks!

Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


can't compile module with apxs

2012-02-27 Thread Rui Hu
hi,

I just tried to write a module which must get core_module's configuration.
So I wrote following code:

#include "http_core.h"

 *core_request_config *reqconf;*
* reqconf = (core_request_config
*)ap_get_module_config(r->request_config, &core_module);*

but I can't compile module with apxs after I added this code line.  Error
message is : "core_reqeust_config & reqconf & core_module undeclared".

Should I add some compile parameters in apxs?

Thanks!

-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


About setting r->headers_out structure

2012-02-27 Thread Rui Hu
hi,

I wrote a module which adds its own field to the HTTP response header by
setting r->headers_out. But nothing happened, I printed out all response
headers but cannot find the filed I set before. This happens in hook
"fixups". What's wrong with it?

Thanks!

-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


Re: can't compile module with apxs

2012-02-28 Thread Rui Hu
Thanks for your advice :-)

Rui Hu

2012/2/27 Nick Kew 

> On Mon, 27 Feb 2012 17:13:52 +0800
> Rui Hu  wrote:
>
>
> > Should I add some compile parameters in apxs?
>
> No, but you should probably have posted to the modules-dev
> list rather than here.
>
> It's not a compile problem, it's a design problem.
> You're trying to use data that's private to another module.
> That means you lose all API support, and a change in the
> core could break your 'module' at any time (and consequently
> you can't in good faith supply it to any third-parties
> as a module, because it'll prevent them upgrading).
>
> Your options are:
>
> 1. Redesign your module not to need core internals.
> 2. Copy the relevant declarations, and live with the consequences.
> 3. Propose a change to the core API to expose whatever you need.
>
> Your best option is probably the first.
>
> --
> Nick Kew
>



-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-


Re: one problem when calling ap_get_module_config

2012-02-29 Thread Rui Hu
thanks!

Problem solved. It the problem with internal redirects.

2012/2/29 Nick Kew 

>
> On 29 Feb 2012, at 10:47, Rui Hu wrote:
>
> > I use r->request_config to store module data as a substitute for global
> > vars. One type_checker_hook function uses ap_get_module_config at its
> > beginning. But what I got is NULL. Strangely, post_read_request_hook
> > function works fine, whose codes is basically the same.
>
> Any subrequests or internal redirects involved?  Look carefully at the
> request object itself.
>
> Or tyops?
>
> --
> Nick Kew
>
>


-- 
Best regards,

Rui Hu

State Key Laboratory of Networking & Switching Technology
Beijing University of Posts and Telecommunications(BUPT)
MSN: tchrb...@gmail.com
-