LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-19-2014, 01:28 PM   #1
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Rep: Reputation: Disabled
$_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.

I use Ubuntu 12.04 on a Dell Desktop.

Thank you in advance,

~faizlo

Last edited by faizlo; 06-19-2014 at 01:33 PM.
 
Old 06-20-2014, 01:37 AM   #2
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
The issue probably has more to do with Apache config (HTTPD)
Take a look here. If you have any questions, post back.
 
Old 06-20-2014, 01:44 AM   #3
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
The variable is $_SERVER['DOCUMENT_ROOT']. Did you restart the server after the changes in config?
 
Old 06-20-2014, 05:04 AM   #4
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
Thanks for the reply.

@j-ray:
Yes, it is $_SERVER['DOCUMENT_ROOT'] in my scripts, sorry for the typo. And yes, I did restart apache2.

@dijetlo
I am reading the link you sent. I will come back after I try some of its solutions.

~faizlo
 
Old 06-20-2014, 05:30 AM   #5
rhoekstra
Member
 
Registered: Aug 2004
Location: The Netherlands
Distribution: RedHat 2, 3, 4, 5, Fedora, SuSE, Gentoo
Posts: 372

Rep: Reputation: 42
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?
 
Old 06-20-2014, 06:09 AM   #6
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
Hi rhoekstra

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.

Thanks,

~faizlo
 
Old 06-20-2014, 07:12 AM   #7
rhoekstra
Member
 
Registered: Aug 2004
Location: The Netherlands
Distribution: RedHat 2, 3, 4, 5, Fedora, SuSE, Gentoo
Posts: 372

Rep: Reputation: 42
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?
 
Old 06-21-2014, 12:33 AM   #8
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
rhoekstra

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)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache2 still looking at var/www somehow gregAstley Linux - Newbie 7 08-18-2012 12:41 PM
[PHP] How to make a path $_SERVER['DOCUMENT_ROOT'] plus one more dir? Mr. Alex Programming 2 04-23-2012 04:51 AM
/var/www & public_html Mat1337 Linux - Server 10 02-24-2011 02:23 PM
[SOLVED] Using /var/www vs. /srv vs. /home/user/public_html NightSky Linux - Server 11 09-06-2010 12:30 AM
Who should own /var/www and it's contents? morrolan Linux - Server 4 04-03-2007 02:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration