更改文件夹的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?

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.