Skip to content

Instantly share code, notes, and snippets.

@jhowbhz
Created May 17, 2024 05:40
Show Gist options
  • Save jhowbhz/f04b37edefcad84636ec3bc7ba566ef5 to your computer and use it in GitHub Desktop.
Save jhowbhz/f04b37edefcad84636ec3bc7ba566ef5 to your computer and use it in GitHub Desktop.
Permissions security laravel php nginx
# Caminho do projeto Laravel
LARAVEL_PATH=/opt/...
# Alterar proprietário e grupo
sudo chown -R www-data:www-data $LARAVEL_PATH
# Permissões para diretórios
find $LARAVEL_PATH -type d -exec chmod 755 {} \;
# Permissões para arquivos
find $LARAVEL_PATH -type f -exec chmod 644 {} \;
# Exceções: Diretórios de armazenamento e cache
sudo chown -R www-data:www-data $LARAVEL_PATH/storage
sudo chown -R www-data:www-data $LARAVEL_PATH/bootstrap/cache
sudo chmod -R 775 $LARAVEL_PATH/storage
sudo chmod -R 775 $LARAVEL_PATH/bootstrap/cache
# Permissoes do .env
sudo chown root:www-data $LARAVEL_PATH/.env
sudo chmod 640 $LARAVEL_PATH/.env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment