SELinux influences "failed to open stream: Permission denied” PHP error -


yesterday i've spent 5 hours straight discovering seemingly unreasonable error "failed open stream. permission denied", occuring after operations of writing file system: fopen (with "w" , "a" flags), move_uploaded_file, file_put_contents.

i've rechecked many times directories owner (user , group - chown, chgrp), have change folder attributes unsecure 777 (rwx chmod), has no effect. reinstalled apache , php, still facing same error.

as appeared after hours of reading various documentation origin of error selinux restrictions automatically applied apache service httpd. i've turned off selinux editing /etc/selinux/config file on fedora (release 20) via changing line:

selinux=enforcing 

to

selinux=disabled 

i restarted computer , annoying error had dissapeared.

i have notice questions @ stack overflow regarding issue of "permission denied" on lamp environment touching folder permission concerns not case in case.

  1. (practical) how can grant apache httpd service write-delete-update permissions on directory without totally disabling selinux?

  2. (theoretical) selinux? intended for? why (for reason) created? why should use it? there reason keep selinux enabled on local dev machine?

solely moderators of resource: know issue covers more administrating actual programming, i'm sure affects developers in more severe way novice administrators, choosing between superuser , stackoverflow took latter. whether move question @ superuser or keep @ place.

i not expert have had few issues selinux myself. read few articles , can gather selinux layer of security server , should left on, rather switched off due ignorance (that quote read, not words). found site helpful , comical , give more info ever could.

http://stopdisablingselinux.com/

a few things have encountered share are:

you can check current selinux permissions following command:

ls -lz 

you can set selinux permissions following command:

chcon unconfined_u:object_r:httpd_user_content_t:s0 

you can use wildcard change files in directory so:

chcon unconfined_u:object_r:httpd_user_content_t:s0 * 

you can set permissions files , directories recursively using (this command fix permission issue, should avoid 777 plague):

chcon -r unconfined_u:object_r:httpd_user_content_t:s0 * 

if wish use home directories serve sites or applications, need issue command:

setsebool -p httpd_enable_homedirs=1 

i have had issues fsockopen on centos selinux , had use following (the -p makes change permanent, liekly need command also):

setsebool -p httpd_can_network_connect 1 

you can see flags set on httpd with:

sestatus 

i think final thing, had issue public/private key authentication on server , needed run command fix (this known bug believe):

restorecon -r -v /home 

hopefully of these snippets , info of use , these not ramblings of mad man.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -