Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel File Permissions

Assuming www-data is the webserver user.

It's not needed but for the sake of shortening commands we will set the LARAVEL_ROOT env variable to the root of our laravel app.

LARAVEL_ROOT=/path/to/your/laravel/root/directory

Change the ownership of our project folder.

sudo chown -R www-data:www-data $LARAVEL_ROOT

Give permission for the files and folder to the machine and webserver user.

sudo find $LARAVEL_ROOT -type f -exec chmod 644 {} \; 
sudo find $LARAVEL_ROOT -type d -exec chmod 775 {} \;

Give the webserver the rights to read and write storage and bootstrap folders.

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

Assuming www-data is the webserver user.

It's not needed but for the sake of shortening commands we will set the LARAVEL_ROOT env variable to the root of our laravel app.

LARAVEL_ROOT=/path/to/your/laravel/root/directory

Change the ownership of our project folder.

sudo chown -R www-data:www-data $LARAVEL_ROOT

Files and folders permissions.

sudo find $LARAVEL_ROOT -type f -exec chmod 644 {} \; 
sudo find $LARAVEL_ROOT -type d -exec chmod 755 {} \;

Give the webserver the rights to write application data.

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment