$_server[' PATH ' value issues

Source: Internet
Author: User
Problem with $_server[' PATH ' value
Hello everyone.
I have two files, one of which is phpinfo.php.
PHP Code
  
   
  
   


The other file is test.php inside only
PHP Code
  
   
  
   


Below the command line, I log in using the User/group username in the Phpinfo page.
Execute PHP test.php

path for output and path to run http://localhost/test.php output in the browser
The content department is consistent, does anyone know why?

Obviously the same user name one executes under the command line, one executes with webpage
The difference is one through Apache, a no, but I also use the Apache httpd.conf username ah.
Why is the output path inconsistent?
Please help to see, thank you!!


------Solution--------------------
$_server[' PATH ']
Is the value of the operating system environment variable PATH, the same machine is naturally the same
------Solution--------------------
Not understand, phpinfo inside the User/group is that Apache run the valid user ID and valid user group ID?

Oh.

You one is Apache access, one is cut into Apache user, then PHP executes, right?

Of course different, because Apache is the root boot bound 80 port, root user path is with sbin path, tied 80 is cut into user/group, but you have to know that the environment variables are inherited from the shell, While the shell environment variable is based on the user who started the Apache process, and you start Apache user is Root,root shell process environment variable is with sbin, so the Apache process started to inherit the shell environment variable, also with Sbin, Setuid does not change the process environment variable after bind in Apache.

And you directly to User/group execute PHP, the reason is obvious, the ordinary user's shell process does not have sbin path, so the PHP interpreter process will not sbin PATH environment variable.
------Solution--------------------
"Path_translated"
The base path to the file system (not the document root) where the current script resides. This is the result of the server making a virtual-to-real-path image.

Note: After PHP 4.3.2, path_translated is no longer implicitly assigned in Apache 2 SAPI mode as Apache 1, but if Apache does not generate this value, PHP generates and puts its values into Script_filename In the service constant. This modification complies with the CGI specification, and path_translated exists only under the conditions defined by PATH_INFO.

Apache 2 users can use Acceptpathinfo on in httpd.conf to define PATH_INFO.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.