Skip to content

Instantly share code, notes, and snippets.

@mdutt247
Last active July 7, 2025 17:09
Show Gist options
  • Save mdutt247/86704dc9abfcf497708b691128ea68b5 to your computer and use it in GitHub Desktop.
Save mdutt247/86704dc9abfcf497708b691128ea68b5 to your computer and use it in GitHub Desktop.
Correct way to set up file and directory permissions in Laravel
# Author: M. Dutt ([email protected])
# Date: 20/11/2023
# Purpose: Correct file and directory permissions of Laravel project.
#
Change the owner and group of your Laravel project.
sudo chown -R developer:www-data /var/www/project
OR
sudo chown -R developer:apache /var/www/project
Directories within Laravel should have a permission level of 755. This allows the owner to read, write, and execute, while the group and others can read and execute.
sudo find /var/www/project -type d -exec chmod 755 {} \;
The "storage" and "bootstrap/cache" directories need to be writable by web server user (www-data/apache). So set their permissions to 775, giving the owner and group read, write, and execute permissions, while others can only read and execute.storage.
sudo chmod -R 775 /var/www/project/storage
sudo chmod -R 775 /var/www/project/bootstrap/cache
Files within Laravel should have a permission level of 644. This allows the owner to read and write, while the group and others can only read.
sudo find /var/www/project -type f -exec chmod 644 {} \;
Verify the list of all the executable files.
sudo find /var/www/project -type f -executable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment