LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-09-2011, 05:32 AM   #1
crowx
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Rep: Reputation: 0
Apache cant see document root


I have set up apache on Centos 5.5 and am struggling with vhosts set up.

With the config I have set apache will correctly serve sites with a document root of

/var/www/html

/home/myuser/public_html

but not

/home/myuser/projects

> ls -al
shows public_html and projects as having identical permissions (755)

Code:
drwxr-xr-x 6 myuser myuser 4096 Feb  8 10:05 .
drwxr-xr-x 3 root    root    4096 Feb  7 15:37 ..
drwxr-xr-x 4 myuser myuser 4096 Feb  7 17:21 projects
drwxr-xr-x 4 myuser myuser 4096 Feb  9 10:21 public_html
and for the purposes of testing both directories contain an index.html file with the same 755 permission.

When I restart the httpd service I get:
Code:
[root@localhost conf]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: Warning: DocumentRoot [/home/myuser/projects] does not exist
                                                           [  OK  ]
My vhosts file contains:

Code:
<VirtualHost *:80>
  ServerName test.localdev
  DocumentRoot /home/myuser/projects

  <Directory "/home/myuser/projects">
    options Indexes Includes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
I only have one vhosts file at the moment so for my test I change the DocumentRoot and Directory between projects and public_html, restarting httpd between each change.

Apache error log shows:
Code:
[Wed Feb 09 11:22:24 2011] [error] [client 172.16.55.1] (13)Permission denied: access to / denied
[Wed Feb 09 11:22:24 2011] [error] [client 172.16.55.1] (13)Permission denied: access to /favicon.ico denied
and I get a 403 in the web browser.

I am confused as to what is going on... Everything works if I set doc root and dir as /home/myuser/public_html, but not /home/myuser/projects

Last edited by crowx; 02-09-2011 at 05:57 AM.
 
Old 02-09-2011, 05:42 AM   #2
appilu
Member
 
Registered: Jan 2011
Distribution: RedHat,Debian-Ubuntu,Fedora
Posts: 73

Rep: Reputation: 8
hi,
As a trial jst give project folder full permission and try.then configure required permission.
 
Old 02-09-2011, 05:48 AM   #3
crowx
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
I have just set projects and the projects/index.html file to 777, but Apache is still reporting the same problem and I'm still getting a 403 in the browser. (I did restart the httpd service.)
 
Old 02-09-2011, 05:55 AM   #4
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,627

Rep: Reputation: Disabled
Your Virtualhost tag does not seem to end anywhere. Just a typo or something?
 
Old 02-09-2011, 05:58 AM   #5
crowx
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by linuxlover.chaitanya View Post
Your Virtualhost tag does not seem to end anywhere. Just a typo or something?
Yeah, sorry. It was on the next page when I copied the text so I missed it.
It is there, and I have added it to the op.
 
Old 02-09-2011, 06:03 AM   #6
appilu
Member
 
Registered: Jan 2011
Distribution: RedHat,Debian-Ubuntu,Fedora
Posts: 73

Rep: Reputation: 8
hi,
403 seems something related to permission for webuser
can u do one thing.jst backup the projects directory then take a copy of public_html ,rename it to projects and give a try.
if its ok copy contents from backuped project folder.
jst a suggestion.
 
Old 02-09-2011, 06:06 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,627

Rep: Reputation: Disabled
You can for time being turn off the SELinux and see if it works. Just check.
 
Old 02-09-2011, 06:17 AM   #8
crowx
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by linuxlover.chaitanya View Post
You can for time being turn off the SELinux and see if it works. Just check.
Great, that worked! Thanks.

I did

Code:
[root@localhost myuser]# echo 0 >/selinux/enforce
[root@localhost myuser]# cat /selinux/enforce
0
And now it works. So, whats going on there? I dont know what SELinux is - just quickly googled to find out how to turn it off. Is it safe to leave it off?
 
Old 02-09-2011, 06:43 AM   #9
crowx
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by appilu View Post
hi,
403 seems something related to permission for webuser
can u do one thing.jst backup the projects directory then take a copy of public_html ,rename it to projects and give a try.
if its ok copy contents from backuped project folder.
jst a suggestion.
Ok, odd.

So I re-enabled SELinux
Backed up projects to projects.bac
Moved public_html to projects
- and now that one works. Apache restarts fine and serves the page.
So I copied projects back to public_html
- and now public_html doesnt work. It gives the same errors that projects used to.

?!!
 
Old 02-09-2011, 07:19 AM   #10
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,627

Rep: Reputation: Disabled
You will need to configure SELinux to allow apache to read from your home directory. If your system is not a production apache server, you can safely turn SELinux off. You can go to SELinux configuration tool from GUI and configure it to allow apache to read the directories if you want it running. Your take. I keep it off on non production machines.
 
Old 02-09-2011, 08:25 AM   #11
crowx
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by linuxlover.chaitanya View Post
You will need to configure SELinux to allow apache to read from your home directory. If your system is not a production apache server, you can safely turn SELinux off. You can go to SELinux configuration tool from GUI and configure it to allow apache to read the directories if you want it running. Your take. I keep it off on non production machines.
Brilliant. Thanks for your help. httpd_enable_homedirs was set to 1 which was fine, but of course my project directory did not have the right context for Apache to serve files from it.

The solution was to do
Code:
chmod 711 /home/myuser
chmod 755 /home/myuser/public_html
chmod 755 /home/myuser/projects
setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_sys_content_t /home/myuser/public_html
chcon -R -t httpd_sys_content_t /home/myuser/projects
service httpd restart
I found this here, after I searched for help on configuring SELinux as a result of the above posts.

Thanks again guys.
 
Old 02-09-2011, 11:21 PM   #12
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,627

Rep: Reputation: Disabled
Great you got it working.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Apache Document Root conflict JPDemole Linux - Software 5 05-22-2009 12:37 PM
Apache Document Root Re-Direct? carlosinfl Red Hat 1 07-09-2007 07:45 PM
altering document root for apache pbhj Linux - Server 3 09-04-2006 07:05 PM
Apache 2: won't allow document root to be changed, plus more QtCoder Linux - Networking 1 11-06-2004 04:44 PM
Document Root in Apache Hal Linux - Newbie 2 10-28-2003 06:10 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration