Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stiucsib86/6fb4c4927cd157c37b19942c835e3195 to your computer and use it in GitHub Desktop.
Save stiucsib86/6fb4c4927cd157c37b19942c835e3195 to your computer and use it in GitHub Desktop.
Changing User Permission when running Laravel Artisan Command or Scheduling Crontab
# If you are running into following error when running Laravel Artisan commands:
# The stream or file "/opt/bitnami/apps/{projects}/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
#
# This is caused by the logs/cache files owned by "daemon" (or www-data) user. To resolve this, you can run the command under the correct user, e.g:
$ sudo -u daemon php artisan schedule:run
# Similarly, if you want to schedule cronjobs, you can also
$ crontab -e
# Then change the user before running Artisan Commands, e.g. :
* * * * * cd /opt/bitnami/apps/{projects}/ && sudo -u daemon /opt/bitnami/php/bin/php artisan schedule:run >> /home/bitnami/logs/cron.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment