about uscontact

How to solve laravel permission denied errors

Category:
Author: zemna
Date: January 26, 2022
Share this:

Laravel system can have various permission denied errors when running in production server.

Clear all cache

php artisan cache:clear

If you get error to clear cache, exeucte command using sudo.

sudo php artisan cache:clear

Check correct permission to storage & bootstrap/cache folder

sudo find . -type f -exec chmod 664 {};
sudo find . -type d -exec chmod 775 {};
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

Check supervisor execution user

When you running Laravel queue by supervisor, specify www-data user.

Set user in your supervisor configuration file. (ex. /etc/supervisor/conf.d/larvel-worker.conf)

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/my-app/artisan queue:work --timeout=300
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/my-app/worker.log
stopwaitsecs=300

Check laravel scheduler user

Generally, laravel scheduler runs by cron job. You need to specify user which can access in your laravel application folder.

* * * * * www-data php /var/www/my-app/artisan schedule:run >> /dev/null 2>&1

Access your web application using custom domain

You can access your web application with custom domain.

Share this:

Leave a Reply

Your email address will not be published.

ZEMNA.NET

Professional software development agency estalished in Indonesia. We offers website setup, web application development, fulfillment service, and etc.
Follow us
Follow us to get latest news and tutorials.
2022 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
magnifiercrossmenu