Laravel 5.6 - permission denied on logs/laravel.log ubuntu xenial 16.04

admin

Administrator
Staff member
Have visited topics on this before to no avail - struggling to get rid of a permissions error "Failed to open stream" on logs/laravel.log, the <em>only</em> thing that works at the moment is setting directory permissions to 777, that of course in a live server production environment is extremely bad practice.

I've followed practically every tutorial, like this one for example is the most recent I've come across:

<a href="https://vijayasankarn.wordpress.com...tting-file-permissions-for-laravel-framework/" rel="nofollow noreferrer">https://vijayasankarn.wordpress.com...tting-file-permissions-for-laravel-framework/</a>

and this

<a href="https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/" rel="nofollow noreferrer">https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/</a>

Generally speaking, some checks I've carried out include checking ownership/groups by running

Code:
ps aux | egrep '(apache|httpd)'

which returns the following results

root 6723 0.0 0.4 77944 4880 ? Ss 14:53 0:00 /usr/sbin/apache2 -k start
www-data 6726 0.0 0.6 432716 6708 ? Sl 14:53 0:00 /usr/sbin/apache2 -k start
www-data 6727 0.0 0.6 432772 6696 ? Sl 14:53 0:00 /usr/sbin/apache2 -k start
ubuntu 6874 0.0 0.0 12948 948 pts/0 S+ 15:07 0:00 grep -E --color=auto (apache|httpd)

So I know my server is owned by www-data - even performing sudo chgrp changes such as ubuntu:www-data had no effect.

I had the same problem in local environment. On production, my blade template is practically rendered as raw text content as opposed to displaying the Laravel error page - assuming it's because the bootstrap/cache (which I've also modified permissions and ownership for) is being unable to be written to/partially written to.

I've also noted that a lot of tutorials mention bootstrap/cache being within the /storage folder but in newer Laravel versions this seems to have moved to /project-directory/bootstrap as opposed to /project-directory/storage/bootstrap etc.

I'm running Ubuntu Xenial 16.04 on an Amazon AWS instance.

Any help would be thoroughly appreciated.