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.
$_SERVER['DOCUMENT_ROOT'] is a PHP global variable for the entire PHP (and web server) configuration set in the the core web server config files (for example the global Apache2 conf file). You can change it there if you have root access.
The box I use is my own box at home. I am using it to learn web programming with PHP and MySQL, so I can do anything I want with it - no problem.
That said, I could configure apache2 to use ~/public_html via commenting few lines in /etc/apache2/mods_available/php5.conf. The instructions were in the file itself.
One other thing is that my httpd.conf file (in /etc/apache2/) has nothing in it, it's empty (of size 0.)
I hope these info can help you figure out how to use ~/public_html/