I spent sometime searching Nginx $_SERVER['DOCUMENT_ROOT'] in Google, most paged I found were talking about how to configure Nginx document root, which was not what I was looking for.
Both configuration are relatively similiar as shown below:
Apache configuration: DocumentRoot /var/www/
Nginx configuration: root /var/www/
However, same setup gives a different result.
Without a doubt, I believe this is a problem of how Apache and Nginx define document_root variable. I create a test file just to print_r $_SERVER variables' values, and I found out:
In Apache:
[DOCUMENT_ROOT] => /var/www/ (This is the default value of root configuration)
But in Naginx:
[DOCUMENT_ROOT] => /var/www (Again, I am using the default location as an example)
As we all know, / differentiates sub directory or part of file name. A simple problem to fix.
Hope this helps someone
--------------------------
个人网页(Personal Website):http://xiangstan.com
Facebook:http://www.facebook.com/xiangs.tan
No comments:
Post a Comment