TL; DR;
Run the following commands on the terminal
More detailed explanation
This usually happens because the web server needs write access to the storage
and bootstrap/cache
directories.
1. Check which user is using the web server process
First, make sure your web server is running under a restricted account. Nginx and Apache usually automatically create and use the less privileged user and www-data
group. You can always use the ps
command to check which user is being used by the current service:
ps aux | grep nginx
2. Set the owner of the project directory
Then, make sure your Laravel project directory belongs to the same user and group that start the web server process. Suppose your web server is running www-data
, and your project directory is in /var/www/laravel
, you can set the ownership as follows:
sudo chown -R www-data:www-data /var/www/laravel
3. Give write access to the storage
and cache
directories
This is an IMPORTANT step, make sure that you give write permission to both the storage
and bootstrap/cache
directories.
sudo chmod -R 775 /var/www/laravel/storage sudo chmod -R 775 /var/www/laravel/bootstrap/cache
Does not work?
If the above steps still do not work, you can try running the following commands in the shell:
# 1. Clear Laravel cache php artisan cache:clear
However, it still does not work?
For the last resource, try setting the resolution to 777
, which means that any users will be able to read and write to the specified directories.
sudo chmod -R 777 /var/www/laravel/storage sudo chmod -R 777 /var/www/laravel/bootstrap/cache
I hope for this help.
source share