Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

How to solve laravel permission denied errors

How to solve laravel permission denied errors

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *