$_SERVER['Document_ROOT'] directs to /var/www not ~/public_html
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
$_SERVER['Document_ROOT'] directs to /var/www not ~/public_html
Hi all,
Exactly like my title says.
I am learning PHP and MySQL and I used to use /var/www/ to host (contain or store) my files (.htm/.php) for testing. I could configure, finally, apache2 to use ~/public_html instead.
Now I when I tried to use $_SERVER['Document_ROOT'] it still directs (I used echo to show its path) to /var/www and not the expected ~/public_html.
My question is: how to make variable ($_SERVER['Document_ROOT']) directs to ~/public_html and not the default /var/www. I found this but I did not understand it. I am totally new to servers/networks.
How did you configure apache2 to use ~/public_html then? what directive in httpd.conf did you alter for that? can you provide such information so we can look along?
I altered php5.conf in /etc/apache2/mods_available/. There is a line there that directs one to change them so user's directory can be used. I mainly commented few lines there.
Then I guess that's the culprit.. the document_root variable is probably the apache document root belonging to the (virtual) host setting in httpd.conf or any of its derivatives (in perhaps httpd.d directory or something). that specific variable has nothing to do with the php.ini file.
Maybe you should browse through the _SERVER variables to see if any other one is more appropriate to use instead of document_root?
My httpd.conf file is empty! It has a 0 (zero) size. That said, I don't know how to do what you suggest. I will be grateful if you can guide me through what you said.
Also, as a side question: What should my /var (and its contents) access permissions be? (I had to chmod /var/www to 777 to test my PHP scripts until I can work from ~/public_html)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.