$document_root Strange Behaviour

admin

Administrator
Staff member
I use the apache variable $DOCUMENT_ROOT for the header of all my php files. It should point to the root of my public directory: <br /><br />/home/hispagi/public_html/ <br /><br />However, it points to: <br />/usr/local/apache/htdocs/ <br /><br />Are there any way of change this behaviour? , my pages don't work for this reason (in other hostings I had not this problem) <br /><br />Thanks in advance.<!--content-->
Hi,<br /><br />cPanel servers use custom binaries so therefore this behavior is standard and can not be modified.<br /><br />All cPanel servers use the same doc root.<!--content-->
Thank you <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> <br /><br />I liked to use $DOCUMENT_ROOT instead of the path, because of the compatibility between the remote host, and my localhost (to testing). Well, thanks.<!--content-->
Head Guru -- can you please reconfirm your answer? <br /><br />Paco expected that $DOCUMENT_ROOT would give /home/{username}/public_html/ but instead got /usr/local/apache/htdocs <br /><br />But when I run either the the phpinfo() script or the env.pl script on a TCH server, they both report back that the contents of $DOCUMENT_ROOT as: /home/{username}/public_html<br /><br />Am i missing something?<br />-kw<!--content-->
I received this message from Alan Ho (summarize):<br />----------<br />I've created a test.php page and it shows document_root being set to the correct<br />home folder. You should check your PHP coding to make sure you are referencing the correct global variable.<br />----------<br /><br />Indeed, at this moment, <b>it works OK</b> , but my old test script was this:<br /><br /><? echo "document root: $DOCUMENT_ROOT"; ?> , and it said:<br />/usr/local/apache/htdocs<br /><br />Now it say:<br />/home/hispagi/public_html<br /><br />Perhaps somebody has changed anything. Well, it's all OK now <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
<b>In this moment I've detected what has happened!:</b><br /><br />If you have this script (called borra.php):<br /><? echo "document root: $DOCUMENT_ROOT"; ?><br /><br />and you go to:<br /><a href="http://207.44.242.2/~hispagi/borra.php" target="_blank">http://207.44.242.2/~hispagi/borra.php</a><br />It shows: /usr/local/apache/htdocs<br /><br />But if you go to (the same, after dns propagation):<br /><a href="http://www.hispagimnasios.com/borra.php" target="_blank">http://www.hispagimnasios.com/borra.php</a><br />it shows: /home/hispagi/public_html<!--content-->
So, the resolution to the problem was to wait until the update for your web / DNS name server had propogated?<br /><br />Good.<br />-kw<!--content-->
I imagine it's not so much a DNS issue as it is an Apache Virtual Host issue. If Apache knows that it's running under <a href="http://www.hispagimnasios.com/" target="_blank">http://www.hispagimnasios.com/</a> (i.e. when the script is called with that as the base URL), it knows that the document root for that Virtual Host is /home/hispagi/public_html. If it is called with the IP number, it doesn't know that the page it is serving exists under <a href="http://www.hispagimnasios.com/" target="_blank">http://www.hispagimnasios.com/</a>, so the document root in that case is just the default server root (/usr/local/apache/htdocs).<br /><br />If that makes any sense. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
 
Top