honeyspoon
honeyspoon

Reputation: 1482

file_put_contents failed to open stream: Permission denied

Basic php and javascript website No errors on Wamp When I put the files on my Lamp server everything works except for this error I get on the top of the page

Warning: file_put_contents(donneesDonut.json): failed to open stream: Permission denied in /var/www/html/bp/action/IndexAction.php on line 101

I looked around and most people suggest to change the permission of the file or the entire directory on apache. chmod 777 did nothing for me.

I'm new to web servers so I probably have missed some apache configuration for permissions during the installation process

Here is a screenshot of the directory Directory listing

I don't think there is a problem with the code since it works on my local Wamp server but here is the line of code that gives me the error.

file_put_contents($this->json, json_encode($this->donneesDonut));

If you need any other information like specific apache configuration please tell me where to get them.

Hope you can help

Upvotes: 1

Views: 4130

Answers (1)

honeyspoon
honeyspoon

Reputation: 1482

The problem was SELinux with was set to enforce by default on Centos

Upvotes: 1

Related Questions