0

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

Henry
  • 5,195
  • 7
  • 21
  • 34

1 Answers1

0

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)'
Nitish Kumar
  • 6,054
  • 21
  • 82
  • 148
  • Thanks. But if the files are pushed via git or other then the permissions are also sent with the files? Or is that not the case... – Henry Sep 17 '19 at 05:02
  • Permissions are also sent, but it doesn't matter when you pull on server, you will have to give the same permission again over there. – Nitish Kumar Sep 17 '19 at 05:03
  • ok thanks for all of this - all very helpful. This is the first time I have experienced this and I have used MAMP, Homestead etc. Is this just because I installed my "sites" direcotory folder (i.e the main directory that contains the Laravel project files) in the wrong place? – Henry Sep 17 '19 at 05:13
  • No, this usually comes on Mac, I face this every time I do a fresh installation or clone new project from repository. – Nitish Kumar Sep 17 '19 at 05:15
  • I definintely well - just a quick question - sorry it is a bit basic but with the command > sudo chmod -R 777 storage/ is "storage" and an example of a directory created by the user or is that a mac thing? (I am on a mac) thanks – Henry Sep 17 '19 at 09:47
  • Generally mac is secure and it doesn't give permission to servers, in case of laravel servers need to have permission to write the storage folder, it can be anything, say your blade templates are cached over there, whatever you upload through laravel application on browser etc. So in some cases you need to give an extra permission for the same. PS Storage is a folder created inside your laravel application when you created the application. – Nitish Kumar Sep 17 '19 at 09:52
  • Thanks for your help you've been really helpful. So just to be clear, the "storage" folder is a preset Laravel directory that comes shipped with Laravel? – Henry Sep 17 '19 at 10:00
  • @henry yes it is. – Nitish Kumar Sep 17 '19 at 10:04