# File\_put\_contents: failed to open stream: Permission denied

**URL:** <https://discourse.cakephp.org/t/file-put-contents-failed-to-open-stream-permission-denied/1360>\
**Category:** Need Help\
**Created:** [October 20, 2016, 1:29pm UTC](https://discourse.cakephp.org/t/file-put-contents-failed-to-open-stream-permission-denied/1360 "2016-10-20T13:29:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndgAlainB](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@ndgAlainB](https://discourse.cakephp.org/u/ndgAlainB)\
**Post date:** [October 20, 2016, 1:29pm UTC](https://discourse.cakephp.org/t/file-put-contents-failed-to-open-stream-permission-denied/1360/1 "2016-10-20T13:29:12Z")

</div>

Hello,  
My problem seems to be the same as exposed [here](http://discourse.cakephp.org/t/resolved-cakephp-3-2-on-centos-7-file-put-contents-permission-denied/491/4), but I cannot resolve it.

I running apache2 on ubuntu server 16.04, and when I enter the command `getenforce`, I get `Disabled`.  
I cannot activate it `setenforce 0` or `setenforce 1` always replies `setenforce: SELinux is disabled`.  
So I modified `/etc/selinux/config` to write `SELinux=enforcing` instead of `SELinux=permissive`.  
Then I rebooted.

Once the machine up, I retried to execute `setenforce 0` or `setenforce 1` but it always replies `setenforce: SELinux is disabled`.

Anyway, `setsebool -P httpd_unified 0`, or `setsebool -P httpd_unified 1` always replies `setsebool: SELinux is disabled`.

What can I do?

---

<div class="post-metadata">

**Author:** ![ndgAlainB](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@ndgAlainB](https://discourse.cakephp.org/u/ndgAlainB)\
**Post date:** [October 20, 2016, 1:55pm UTC](https://discourse.cakephp.org/t/file-put-contents-failed-to-open-stream-permission-denied/1360/2 "2016-10-20T13:55:44Z")

</div>

I solved the problem on this server by setting directory permissions to 777.  
But on my other server directories are set to 755 so, I suppose that apache2 has no correct rights.
