Laravel 5 not getting any error logs Laravel 5 not getting any error logs apache apache

Laravel 5 not getting any error logs


If you've set your file permissions correctly on the /storage file directory and you're running on a VPS not shared hosting you might want to check your apache log, inside var/log/apache2/error.log

Here you might just see a line that read something along the lines of /var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

Well this is strange because you have the correct file permissions...

Let's start by SSH'ing into your VPS head to the directory where laravel is installed normally cd /var/www/html

In here if you run ls -l You should get some results similar to this image below:enter image description here

Notice how we've been accessing the site as the root user, this is our problem and we can confirm this by running ps aux | grep apache2

enter image description here

You can see here apache2 is running as the user www-data, which is normal for apache. Which means when our laravel installation trys to move files either using ->move() or just trying to write the log file it fails as the www-data user doesn't have permission. So you can change to this www-data user by running: chown -R www-data:www-data * (shorthand for same user/group chown -R www-data. *)

Now if you run ls -l in your www/html directory you should see root user changed to www-data:

enter image description here

This means were now editing the files as the www-data user which has permission, so any changes you make via SFTP should reflect this user change. Fixed!

Edit - This is the first time I answered my own question hopefully it's okay.