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

后端 未结 8 777
攒了一身酷
攒了一身酷 2020-12-05 13:54

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

相关标签:
8条回答
  • 2020-12-05 14:26

    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

    0 讨论(0)
  • 2020-12-05 14:27

    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 {} \;
    
    0 讨论(0)
  • 2020-12-05 14:36

    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/

    0 讨论(0)
  • 2020-12-05 14:36

    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 ../
    find storage -type d -exec chmod 775 {} \;
    find storage -type f -exec chmod 664 {} \;
    

    UPDATE 2016 for laravel 5+

    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
    find . -type d -exec chmod 775 {} \;
    find . -type f -exec chmod 664 {} \;
    

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

    0 讨论(0)
  • 2020-12-05 14:43

    Try these commands one by one:

    setenforce 0
    setsebool -P httpd_can_network_connect_db on
    
    0 讨论(0)
  • 2020-12-05 14:44

    just type this on terminal:

    php artisan cache:clear
    
    0 讨论(0)
提交回复
热议问题