Search code examples
laravellaravel-valet

Permission based issue with Valet (so it seems)


I got Valet to work and .test domains can be pinged etc.

However, when I create a laravel new test-site I get a bunch of permission-based errors. I 'sudo'd' the laravel build but I was repeatedly warned not to do this.

If I then view the site on the browser this is the error I get:

enter image description here

and this:

enter image description here

So - is the problem that I placed my "sites" folder (which I can "builds") in an inappropriate section of my machine?

enter image description here


Solution

  • You need to give permission to your storage directory.

    In my local mac I generally do

    sudo chmod -R 777 storage/
    

    But this is vunerable on server/production. I would suggest you should change directory ownership. so set your current user that you are logged in with as owner and the webserver user (www-data, apache, ...) as the group. You can try this:

    sudo chown -R $USER:www-data storage
    sudo chown -R $USER:www-data bootstrap/cache
    

    then to set directory permission try this:

    chmod -R 775 storage
    chmod -R 775 bootstrap/cache
    

    Webserver user and group depend on your webserver and your OS. to figure out what's your web server user and group use the following commands.

    for nginx use:

    ps aux|grep nginx|grep -v grep
    

    for apache use:

    ps aux | egrep '(apache|httpd)'