-
-
Save sineld/cdde31ed83382d871f9cc5b896ffdb3b to your computer and use it in GitHub Desktop.
Correct way to set up file and directory permissions in Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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