Skip to content

Instantly share code, notes, and snippets.

@LostinOrchid
Last active July 13, 2020 00:32
Show Gist options
  • Save LostinOrchid/87d5f73b6fa1be558785f60f74b72bce to your computer and use it in GitHub Desktop.
Save LostinOrchid/87d5f73b6fa1be558785f60f74b72bce to your computer and use it in GitHub Desktop.
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