It is not recommended to set a directory's permission to 777. Instead, you should consider changing the directory ownership. To achieve this, you can set the current user that you're logged in with as the owner and the web server user (which could be www-data, apache, or similar) as the group. You can then set the directory permissions to 775 by running the following commands
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
chmod -R 775 storage
chmod -R 775 bootstrap/cache
By doing this, you are granting read, write, and execute permissions to the owner and group, while only allowing read and execute permissions to others. This can help improve the security and integrity of your directories.