Re: questions about document_root

2011-12-08 Thread Mark Montague

On December 8, 2011 1:48 , Rui Hu tchrb...@gmail.com wrote:

2011/12/8 Rui Hu tchrb...@gmail.com mailto:tchrb...@gmail.com

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.



What you say is correct.  This is an Apache HTTP Server mailing list.  
You said, in apache, I cannot find any code which assign this var. and 
I showed you where in Apache HTTP Server the DOCUMENT_ROOT environment 
variable is set when running CGIs.


What you are now asking should be sent to the PHP users mailing list, 
since it is a question about PHP.  But, see the function 
init_request_info() in the PHP source code, in the file 
sapi/cgi/cgi_main.c (lines 1123-1137)


http://svn.php.net/viewvc/php/php-src/branches/PHP_5_3_8/sapi/cgi/cgi_main.c?revision=315335view=markup

How PHP determines the value of $_SERVER[DOCUMENT_ROOT] depends on all 
of the following:


- The value for the PHP directive cgi.fix_pathinfo
- The value for the PHP directive doc_root
- The value of the environment variable DOCUMENT_ROOT (set by Apache 
HTTP Server)


--
  Mark Montague
  m...@catseye.org



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 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

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 n...@webthing.com


 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 Mark Montague

On December 7, 2011 23:23 , Rui Hu tchrb...@gmail.com 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=1100216view=markup


--
  Mark Montague
  m...@catseye.org



Re: questions about document_root

2011-12-07 Thread Rui Hu
2011/12/8 Rui Hu tchrb...@gmail.com

 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 m...@catseye.org

 On December 7, 2011 23:23 , Rui Hu tchrb...@gmail.com 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=**1100216view=markuphttps://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/server/util_script.c?revision=1100216view=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
-