Laravel 5.2 could not open laravel.log
TLDR;
Run the following commands on your terminal
# Clear Laravel cache and the compiled classesphp artisan cache:clearphp artisan clear-compiled# Change the storage and cache directories permissionsudo chmod -R 777 storagesudo chmod -R 777 bootstrap/cache# Regenerate the composer autoload filecomposer dump-autoload
More thorough explanation
This usually happens because of the web server needs a write access to the storage
and bootstrap/cache
directories.
1. Check which user is being used by web server process
First, make sure that your webserver process is run by an account with limited privileges. Nginx and Apache usually will automatically create and use the less privileged www-data
user and group. You can always use the ps
command to check which user is being used by the running service:
ps aux | grep nginx
2. Set the owner of your project directory
Next, make sure that your Laravel project directory is owned by the same user and group who run the web server process. Suppose your web server is run by www-data
and your project directory is located at /var/www/laravel
, you can set the ownership like so:
sudo chown -R www-data:www-data /var/www/laravel
3. Give a write access to storage
and cache
directories
This is the IMPORTANT step, make sure you give the write permission both to storage
and bootstrap/cache
directories.
sudo chmod -R 775 /var/www/laravel/storagesudo chmod -R 775 /var/www/laravel/bootstrap/cache
Still Not Working?
If the above steps are still not working, you can try to run the following commands in the shell:
# 1. Clear Laravel cachephp artisan cache:clear# 2. Delete the compiled classphp artisan clear-compiled# 3. Regenerate the composer autoload filecomposer dump-autoload
Yet, it still not working?
For the last resource, try to set the permission to 777
which means any users will have the ability to read and write to the given directories.
sudo chmod -R 777 /var/www/laravel/storagesudo chmod -R 777 /var/www/laravel/bootstrap/cache
Hope this help.