Friday, August 7, 2015

php - apache on centos 5.6 gives me permissions denied error



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"


Options Indexes FollowSymLinks
AllowOverride None

Order allow,deny
Allow from all



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



as well: i also have REMI and EPEL enabled


Answer



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


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...