Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

services.json failed to open stream: Permission denied in Laravel 4

I was playing around with a working Laravel 4 installation and moved everything into a sub folder. Then I decided to not do that and I moved it all back (all via the command line):

mv * /folder

and then

cd folder
mv * ../

Now, the site is throwing the following error:

file_put_contents(/var/www/quantquote/app/storage/meta/services.json): failed to open stream: Permission denied

Here is a screenshot of the full error:

http://i.imgur.com/8deGG97.png

I've already tried setting permissions on the /storage folder to 777 to no avail.

like image 688
JasonStockman Avatar asked Jul 30 '13 18:07

JasonStockman


3 Answers

Spent a whole day for solving this and this command simply solved my problem.

If your permissions are 777 for Laravel App folder and you still get this error, it's because SEliux has blocked it. You can easily unblock your application's folder using this command:

su -c "chcon -R -h -t httpd_sys_script_rw_t /usr/share/nginx/YOUR_LARAVEL_APP/"

That's it!

BTW never disable SElinux: http://stopdisablingselinux.com/

like image 118
Sky Avatar answered Nov 15 '22 21:11

Sky


As I stated in my comment:

find app/storage -type d -exec chmod 777 {} \;

find app/storage -type f -exec chmod 777 {} \;

This will chmod all directories and files in app/storage to 777.

like image 43
Collin Henderson Avatar answered Nov 15 '22 19:11

Collin Henderson


As the problem is related to permissions try re-giving the right permissions to app/storage and all its sub-directories and file.

You can do so from the root path of your Laravel app typing:

chmod -Rvc 777 app/storage

If for some reason this doesn't work, try:

find app/storage -type d -exec chmod -vc 777 {} \;
find app/storage -type f -exec chmod -vc 777 {} \;
like image 11
Rubens Mariuzzo Avatar answered Nov 15 '22 21:11

Rubens Mariuzzo