SELinux preventing Apache from writing to a file
Solution 1:
As already stated, you should instruct SELINUX to allow writing to that file. The right thing to do is to mark /var/www/webapp/k/site/
as of type httpd_sys_rw_content_t
To permanently mark that directory as httpd_sys_rw_content_t
, you can use the command semanage fcontext -a -t httpd_sys_rw_content_t /var/www/webapp/k/site(/.*)?; restorecon -RF /var/www/webapp/k/site/
This will survive SELINUX binary policy updates and filesystem relabeling.
Solution 2:
For files you want Apache to be able to write to, the type must be set to httpd_sys_rw_content_t
.
Solution 3:
This will change the permissions:
chcon --type httpd_sys_rw_content_t /var/www/webapp/k/site/k.log