Skip to content

Instantly share code, notes, and snippets.

@ezequiel9
Last active November 8, 2020 08:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezequiel9/f44d0354eca8f21e0fd0cc0f60cf89eb to your computer and use it in GitHub Desktop.
Save ezequiel9/f44d0354eca8f21e0fd0cc0f60cf89eb to your computer and use it in GitHub Desktop.
How to proper set up Laravel Permissions
Your user as owner
I prefer to own all the directories and files (it makes working with everything much easier), so I do:
# sudo chown -R my-user:www-data /path/to/your/laravel/root/directory
Then I give both myself and the webserver permissions:
# sudo find /path/to/your/laravel/root/directory -type f -exec chmod 664 {} \;
# sudo find /path/to/your/laravel/root/directory -type d -exec chmod 775 {} \;
Then give the webserver the rights to read and write to storage and cache
Whichever way you set it up, then you need to give read and write permissions to the webserver for storage, cache and any other directories the webserver needs to upload or write too (depending on your situation), so run the commands from bashy above :
# sudo chgrp -R www-data storage bootstrap/cache
# sudo chmod -R ug+rwx storage bootstrap/cache
Now, you're secure and your website works, AND you can work with the files fairly easily
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment