0

I have my project in local development and all it's working fine.

When I pass the project to a rasberry and try to make it works I'm getting some errors I try to find the solution in other questions like this here in stackoverflow but it not works.

When I call to a function who it's working with storage folder I get this error:

With sudo chmod -R 775 storage/

The stream or file "/var/www/html/test/storage/logs/laravel.log" could 
not be opened: failed to open stream: Permission denied

And if I change the permission to 777 I get this error:

file_put_contents(/var/www/html/test/resources/views/projects/problema.blade.php): failed to open stream: Permission denied

How should be the permission of the folder to make it works?

Lluís Puig Ferrer
  • 1,128
  • 7
  • 19
  • 49

1 Answers1

0

This is what i used to do for the linux installations :

sudo usermod -a -G apache your_user
sudo chown -R your_user:apache /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;

You should be fine with these permissions.You can replace the group and user and you need. Never provide a 777 permission to any of the folders.

Shan
  • 1,081
  • 1
  • 12
  • 35
  • Ok, let me ask you first something. I'm on a rasberry with some users. If I write `whoami` I get my user Lluis. Also in /var/www I have more folders that aren't mine. My folder location is: /var/www/html/test. So my commands will be this? 1 - `sudo usermod -a -G apache lluis` 2 - `sudo chown -R lluis:apache /var/www/html/test` 3 - `sudo chmod 2775 /var/www/html/test` 4 - `find /var/www/html/test -type d -exec sudo chmod 2775 {} \;` and finally 5 - `find /var/www/html/test -type f -exec sudo chmod 0664 {} \;` – Lluís Puig Ferrer Jan 18 '18 at 11:50
  • I wan't to be sure I don't touch anything isn't mine @Shan – Lluís Puig Ferrer Jan 18 '18 at 11:50
  • can you check what is the permission given to /var/www folder ? – Shan Jan 18 '18 at 11:59
  • Yes @Shan drwxr-xr-x to www folder – Lluís Puig Ferrer Jan 18 '18 at 12:00
  • Ok, so you have 755 for www, and confirm the owner/group info also – Shan Jan 18 '18 at 12:05
  • I have also 755 on /html and on /test, the owner/group of info is root @Shan – Lluís Puig Ferrer Jan 18 '18 at 12:09
  • So, "The owner has read, write and execute permissions; the group and others can only read and execute". Im not sure that you still have the write permission because your user/group seems root/root respectively. try those commands that you mentioned in your first command. – Shan Jan 18 '18 at 12:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/163407/discussion-between-lluis-puig-ferrer-and-shan). – Lluís Puig Ferrer Jan 18 '18 at 12:25