dongsu1951 2014-10-05 19:39 采纳率: 0%
浏览 50

更改文件夹的php文档根目录

While i host my site online, i keep a local copy on my computer, which is running fedora 20 and apache server, for testing purposes. However i have stumbled trying to use the $_SERVER['DOCUMENT_ROOT'] variable in php.

On my web server, the document root is: /var/www/httpdocs whereas on my computer the document root is: /var/www/html/mysite.

Is there a way to change the apache document root on my local server to be the same in the php variable?

  • 写回答

1条回答 默认 最新

  • douyong1974 2014-10-05 19:52
    关注

    It sounds like you're trying to differentiate the production and development environments, a better way of doing that would be to create an environment variable that PHP will read and will then load the correct configurations for that environment.

    You can set an environment variable by using the following instruction in your virtual host file: SetEnv env-variable [value]

    Read the variable in php by using getenv function:

    getenv ( string $varname )
    

    You can read more about enviorment variables in apache in greater detail in apache website.

    评论

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘