PHP document root

From SME Server
Jump to navigation Jump to search

Document Root issue

$_SERVER['DOCUMENT_ROOT']

If you set up an application in an ibay you may have some odd results due to the usage of $_SERVER['DOCUMENT_ROOT'] by the application.

By default this is set in php.ini to :

/home/e-smith/files/ibays/Primary/html

This can cause lots of issues.

To test this, create a file called phpinfo.php in the root html folder of your ibay.

nano /home/e-smith/files/ibays/ibayname/html/phpinfo.php

Now add the following line :

<?php     
phpinfo();     
?>

Save by ctrl+x And access it with a browser :

http://yourhost.myserver.com/mybay/phpinfo.php

Look for the Document Root setting.

How to overcome $_SERVER['DOCUMENT_ROOT'] issues in ibays

The simplest way to avoid this is to setup a subdomain and point it to the ibay.

For example

Your current host/domain : yourhost.myserver.com

In server-manager Add Domain :

Domain Name : test.myserver.com
i-bay       : mybay
DNS Servers : resolve locally

Now you can access the mybay directory like this :

http://test.myserver.com

Try phpinfo.php

http://test.myserver.com/phpinfo.php

If you want external access then create a new A record with your DNS hosting pointing your IP address to test.myserver.com