services.json failed to open stream: Permission de

2019-01-14 02:28发布

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.

8条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-14 02:33

When chmod 777 or chmod 775 fails check that subdirectories really exists:

app/storage/
├── cache
├── logs
├── meta
├── sessions
└── views

in case these folders does not exists you must to create it:

cd app/storage/
mkdir meta logs cache sessions views
cd ../../
chmod -R 777 app/storage

UPDATE 2016

In a default Laravel 5 application structure, storage is at the same level than app. So the previous command becomes:

cd storage/
mkdir meta logs cache sessions views
cd ../
chmod -R 777 storage

https://laravel.com/docs/5.0/structure

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-14 02:35

Try these commands one by one:

setenforce 0
setsebool -P httpd_can_network_connect_db on
查看更多
Juvenile、少年°
4楼-- · 2019-01-14 02:43

Never run a 777, in recursive mode. It's a security issue. For now, remove the services.json file, and try this :

Laravel 4: Failed to open stream: Permission denied

查看更多
闹够了就滚
5楼-- · 2019-01-14 02:45

just type this on terminal:

php artisan cache:clear
查看更多
做自己的国王
6楼-- · 2019-01-14 02:47

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/

查看更多
闹够了就滚
7楼-- · 2019-01-14 02:49

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.

查看更多
登录 后发表回答