dongzhang5787
dongzhang5787
2015-03-11 12:15
浏览 148
已采纳

$ _SERVER ['HOME']没有显示正确的值nginx ubuntu

I have a nginx server with php5-fpm on ubuntu 14.

when I echo $_SERVER['HOME'] it return back /var/www

my web files located in /usr/share/nginx/html

obviously it's not my home directory if i type ~/ in the terminal I can get the home directory that is /home/myname

I couldn't find where this information set and why it set wrong.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongtan4046
    dongtan4046 2015-03-11 12:19
    已采纳

    $_SERVER['HOME'] returns the home path of the current user.

    If nginx is running as (for example) www-data, then you'll get the home-directory of www-data.

    I guess that you need $_SERVER['DOCUMENT_ROOT'].

    点赞 评论
  • doulin2947
    doulin2947 2015-03-26 16:51

    return value is root of the user that nginx is running under it, usually it's www-data.

    string get_current_user ( void )
    

    you can confirm the current user with get_current_user

    点赞 评论

相关推荐