10

I'm running apache on centos 5.6 and whenever i try to load a php script in any directory, other than /var/www/html (the apache default root dir) it gives me a permissions denied error.

However when i check the permissions of my new root dir (/var/www-dev) against the default dir (/var/www/html), they match identically. both say: root:root 755

i even tried changing the ownership to apache:apache, and still got the same error

But when i change the apache config back it's default root dir (/var/www/html) everything works.

Am i doing something wrong?

These are the settings i am changing:

DocumentRoot "/var/www/html"

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Note: i am restarting apache every time i change the apache config and permissions.

as well: i also have REMI and EPEL enabled

koeder
  • 223
  • 2
  • 9
  • Is SELinux enabled? – Bart De Vos May 23 '11 at 22:44
  • @TiZon i don't believe so. should it be? – koeder May 23 '11 at 22:59
  • Can you give us the exact message? Is this "permission denied" coming from the file system or directly from apache (e.g. by some Order directive)? And are there messages in the error.log file? – Raffael Luthiger May 23 '11 at 23:01
  • And check if you have any .htaccess files in those two subdirectories. – Raffael Luthiger May 23 '11 at 23:02
  • I do have htaccess in those directories. The code in the .htaccess is `RewriteEngine on RewriteRule (.*)/index.php $1/ [L]` However, I think @TiZon was right about the SELinux, it was enabled. I disabled it. rebooted my server and now i can change the apache root dir to another dir with no problem – koeder May 23 '11 at 23:28
  • The exact error msg in my server log was this: `[Mon May 23 18:35:57 2011] [error] [client 192.168.0.101] (13)Permission denied: access to /index.php denied ` – koeder May 23 '11 at 23:29
  • 1
    Thanks @TiZon! SELinux, was enabled. Once i disabled it editing the /etc/selinux/config file, my web apps were able to load in other directors. – koeder May 23 '11 at 23:34

1 Answers1

11

Usually that comes from Selinux not giving access to the folder. do

ls -alZ /var/www/

and if the html folder doesn't have the context system_u:object_r:httpd_sys_content_t, fix it with chcon

chcon -v -R --type=httpd_sys_content_t /var/www/html

http://wiki.centos.org/HowTos/SELinux

Julien Vehent
  • 3,017
  • 19
  • 26
  • Thanks @Julien Vehent! I'll reward you the answer because your method allows me to edit SELinux permissions on a specific folder rather than disabling SELinux all together. Thank you very much. This worked! and saved me a headache. – koeder May 24 '11 at 00:02