LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-13-2012, 06:15 AM   #1
Ortix
LQ Newbie
 
Registered: Oct 2012
Posts: 3

Rep: Reputation: Disabled
[CentOS 5.8] 403 Error when accessing vhost directive (permission problems)


Hey guys,

I'm having some troubles with setting up my webserver. It's a brand new server and I'm trying to set a vhost to the following dir:

/home/exo/public_html

However whenever I restart httpd I get the following warning:
Code:
Starting httpd: Warning: DocumentRoot [/home/exo/public_html] does not exist
Yes the directory does exist. So whenever I visit the domain exo-l.com it gives me a 403 error.

This is my config file (inside httpd.conf because the vhost conf is not being included, that issues will be discussed in another thread once i get this working since it has uber priority)

Code:
<VirtualHost *:80>
   DocumentRoot       /home/exo/public_html
   ServerName         www.exo-l.com
   ServerAlias        exo-l.com
   <Directory /home/exo/public_html>
        Order allow,deny
        Allow from all
   </Directory>
</VirtualHost>
I'm completely clueless because this should work as far as I know.

httpd is being run as apache:apache

i tried chowning the public_html directory (also recursively) to exo:apache, apache:apache, root:root with no success. chmod 777 doesn't do anything either.

a tail from the log:
Code:
[Sat Oct 13 15:09:47 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:09:47 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:09:48 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:10:03 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:10:04 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:10:04 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:10:04 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:10:04 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
[Sat Oct 13 15:10:04 2012] [error] [client 82.***.***.61] (13)Permission denied: access to / denied
I also found something about selinux and that disabling it might help, but do I really want to do that?
 
Old 10-13-2012, 08:05 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

Make sure that you have the execute permissions set on that directory, so apache can descend into it
Code:
chmod 755 /home/exo/public_html
Regards
 
Old 10-13-2012, 08:15 AM   #3
Ortix
LQ Newbie
 
Registered: Oct 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
that was the very first thing i checked.. and like i said in my post i tried 777 (which has read enabled as well)

In other words, that doesn't work

Last edited by Ortix; 10-13-2012 at 08:22 AM.
 
Old 10-13-2012, 08:37 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
If it doesn't work, then it's SELinux. Use:
Code:
chcon -R -t httpd_sys_content_t /home/exo/public_html
and see if it helps
 
Old 10-13-2012, 08:49 AM   #5
Ortix
LQ Newbie
 
Registered: Oct 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Well goddamit that was it 0.o

just one simple trick and that did it!

What was exactly the problem? Why does this happen? Will this also work with phpmyadmin (that is also not accessible due to 403)
 
Old 10-13-2012, 09:14 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Glad to see it worked.
This happens if you change things (like the DocumentRoot) from their default values.
In centos the default docroot is /var/www/html and it's already labeled with the correct SELinux context. If you decide to use a different docroot, you need to label it accordingly.

Cheers
 
Old 10-16-2012, 12:26 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
FYI, chcon does not survive a reboot; you need to add it to SELinux permanently
Code:
semanage -a -t httpd_sys_content_t /home/exo/public_html
 
1 members found this post helpful.
Old 10-19-2012, 10:45 AM   #8
mikey99
Member
 
Registered: Nov 2008
Location: UK
Distribution: RHEL, Fedora
Posts: 68

Rep: Reputation: 12
Quote:
Originally Posted by chrism01 View Post
FYI, chcon does not survive a reboot; you need to add it to SELinux permanently
Code:
semanage -a -t httpd_sys_content_t /home/exo/public_html
Just to add a few comments.

Changing a label WILL survive a reboot, but it may not survive a full filesystem relabel.

However, there is aleady an entry for public_html in the targeted policy. Its not viewable when you do semanage fcontext -l , but it is in the policy. Try it. Create a directory called ~/public_html and run a restorecon -RF on the directory. It will change to httpd_user_content_t.

To be honest, it should automatically type transition to this context on creation. That is the job of the restorecond daemon via inotify. But it sometimes fails to do so, hence the manual running of the restorecon command.

Mike.
 
Old 10-22-2012, 12:04 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
ah yes, sorry 'relabel' .... often happens at reboot
 
  


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
centos, how to prevent vhost client accessing /manual? elfoozo Linux - Server 3 06-12-2012 12:29 AM
[SOLVED] Still getting Apache 403 after adding Directory directive to Alias Joshua Russo Linux - Newbie 21 01-10-2012 06:08 PM
apache 403 forbidden permission to access error windows agentfitz Linux - Server 2 01-19-2011 12:45 PM
Apache 403 Forbidden error when accessing cifs mount guapo42 Linux - Newbie 3 11-16-2009 03:06 PM
permission problems (403) with bugzilla using apache ttilt Linux - Networking 2 07-19-2004 03:58 PM

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

All times are GMT -5. The time now is 10:36 PM.

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