Issue
I have two files which i want read using php. One file is located in /var/www/html
and the other file is located in /svn/access/
(directory which i have created). I can read the file which is in /var/www/html
but the other one cannot be read.
I get the following error message:
Warning: fopen(/svn/access/test): failed to open stream: Permission denied in /var/www/html/svnmanager/test2.php on line 5
I have given permission to all the directories and file using 'chmod' and 'chown'
chown -R apache:apache /svn*
chmod -R 755 /svn
chown -R apache:apache /svn/*
chmod -R 755 /svn/*
But i'm still getting that error, When i try to read from the path /svn/access
. Why is this happening and how can i fix this ? Please help!
Solution
Finally found myself a solution for this.
SELinux blocks httpd to write in any folder other than /var/www/
. Therefore some configurations have to be made.
yum -y install policycoreutils-python
semanage fcontext -a -t httpd_sys_rw_content_t "/svn/access(/.*)?"
restorecon -R /svn/access
Answered By - Chamara Keragala