Laravel proper permissions

14,616

Solution 1

This will work, as777 is a security risk

 sudo chmod -R o+w storage/

 sudo chmod -R 775 storage/

Solution 2

First, check the user assigned in Nginx www conf file /etc/php/7.0/php-fpm.d/www.conf
User may be www-data or _www or any other.

Then change the ownership of the project folder as

sudo chown $USER:www-data -R ~/Laravel/PBlog/

Then Change the file permissions as

sudo chmod u=+srwX,g=+srX,o=rX -R ~/Laravel/PBlog/

s flag means, any file/folder added/created inside the folder will take same permission.

Solution 3

Depending on how you bootstrapped your project, there is already a 775 flag on the storage folder usually, another easy fix, is to add your web server user to your group using usermod with the -aG options : usermod -aG $USER www-data

Share:
14,616
MattJ
Author by

MattJ

I like javascript.

Updated on July 27, 2022

Comments

  • MattJ
    MattJ almost 2 years

    I just tried to change my Laravel project to run on Nginx instead of Apache and can't get the right permissions. Don't really know what to try next. Currently here they are: enter image description here

    I even gave the 777 permission to the storage folder, but nothing works. I have an admin panel on a blog which always keeps throwing

    ErrorException in File.php line 190:
    chmod(): Operation not permitted
    

    Would really appreciate any help.

    I am using Nginx, PHP 7.0, MySQL. The website is written using the Laravel framework.

  • Furquan
    Furquan about 4 years
    I am having user = nobody group = nobody what should be chown command for me?
  • Ankit Balyan
    Ankit Balyan about 4 years
    you can add user and group. nginx.org/en/docs/ngx_core_module.html#user
  • Ankit Balyan
    Ankit Balyan about 4 years