kevineugenius Posted October 10, 2007 Share Posted October 10, 2007 I'm not sure if I'm even asking the right question, but my website (not hosted by me) used codes like include $_SERVER["DOCUMENT_ROOT"] . "/include/header.php";. Per a forum member's suggestion, I ran an echo on that command, and it gives a folder tree three folders deep... So, online, it points to the correct page, but I'm trying to set up Apache (I used WAMP) to get a beta test site on my own computer. So, the above command doesn't work. I ran searches for "document_root" and "php5/pear" (a directory in the error messages I get) to see if I could find a path setting in either Apache or PHP config files with no success. Does anyone know how to set up either my Apache or PHP config so I can define what $_SERVER and DOCUMENT_ROOT are pointing to when they're on my localhost without making them not work when I upload them to my web host? Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/ Share on other sites More sharing options...
freakstyle Posted October 10, 2007 Share Posted October 10, 2007 here's where you would change it: open: \xampp\apache\conf\httpd.conf edit "DocumentRoot "C:/xampp/htdocs" to whatever you are needing it to point to. Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-366610 Share on other sites More sharing options...
kevineugenius Posted October 11, 2007 Author Share Posted October 11, 2007 Bummer... that one's already set up to the correct path. Now I don't actually know what's wrong again. Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-366613 Share on other sites More sharing options...
freakstyle Posted October 11, 2007 Share Posted October 11, 2007 perhaps the folders aren't in the same set up as in your hosted solution. what you'll want to do is find an example case. you say /include/header.php is one of the files it's looking for. so on your local machine, you should have it like this C:/xampp/htdocs/include/header.php your file structure must match what is online, if you want it to work correctly. if this doesn't help, can you paste in some examples of your current hosted file structure and your's (not the full tree please, just enough to see an example) good luck Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-366617 Share on other sites More sharing options...
Cagecrawler Posted October 11, 2007 Share Posted October 11, 2007 WAMP doesn't set doc_root out of the box. You need to go into the php.ini file (Config files>php.ini on the WAMP menu) and search for doc_root (line 433). Set it to the doc root, usually "C:\wamp\www". Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-366624 Share on other sites More sharing options...
kevineugenius Posted October 12, 2007 Author Share Posted October 12, 2007 I tried both doc_root = "c:/wamp/www" and doc_root = ".;c:/wamp/www" with no results. I tried uncommenting include_path, I check apache's file for documentroot settings, I can't find anything that isn't set. You are right, doc_root wasn't set by default, but setting it didn't fix the problem either. Would the problem have anything to do with the $_SERVER variable? Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-367938 Share on other sites More sharing options...
ingeva Posted October 12, 2007 Share Posted October 12, 2007 I use $home = $_SERVER["DOCUMENT_ROOT"]; and it has never given me any problems. Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-368011 Share on other sites More sharing options...
darsh999 Posted October 12, 2007 Share Posted October 12, 2007 I think you must go out with this coding $home = $_SERVER["DOCUMENT_ROOT"]; it will never give you problem in future.. Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-368038 Share on other sites More sharing options...
kevineugenius Posted October 12, 2007 Author Share Posted October 12, 2007 Where do I put that? Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-368104 Share on other sites More sharing options...
kevineugenius Posted October 16, 2007 Author Share Posted October 16, 2007 Alright, so the document_root stuff wasn't the problem at all. The problem was in php.ini short_open_tag = On was set to off. Quote Link to comment https://forums.phpfreaks.com/topic/72696-solved-server-and-document-root-settings-in-apache/#findComment-370963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.