i have deployed my laravel project in ubuntu server
i faced this issue daily
The stream or file "/var/www/html/xxxx-laravel-project/storage/logs/laravel-2024-07-21.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file "/var/www/html/xxxx-laravel-project/storage/logs/laravel-2024-07-21.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: The stream or file
#!/bin/bash
LOG_DIR="/var/www/html/xxxx-laravel-project/storage/logs"
# Set ownership
sudo chown -R www-data:www-data $LOG_DIR
# Set permissions for directories to 775
sudo find $LOG_DIR -type d -exec chmod 775 {} \;
# Set permissions for files to 644
sudo find $LOG_DIR -type f -exec chmod 644 {} \;
# Log the action
echo "Permissions fixed on $(date)" >> /var/log/fix_permissions.log