質問

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/*

enter image description here

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!

役に立ちましたか?

解決

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

他のヒント

have you used sudo?

sudo chown -R apache:apache /svn*
sudo chmod -R 755 /svn

sudo chown -R apache:apache /svn/*
sudo chmod -R 755 /svn/*

you may need to be a super user to change permissions

Always use 4 numbers, i had a lot of trouble because i forgot that. So 0755 would be my suggestion.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top