0

I am trying to get my Laravel 5.3 installation to work on a Amazon Linux AMI EC2 instance.

So far everything is set up:

  • apache, php, etc.. ok
  • laravel set up in www/html/blog

folder permissions were set to 775 (following the AWS docs):

drwxrwsr-x  6 ec2-user www   4096 Sep 20 13:38 app
-rwxr-xr-x  1 ec2-user www   1646 Sep 20 13:38 artisan
drwxrwsr-x  3 ec2-user www   4096 Sep 20 13:38 bootstrap
-rw-rw-r--  1 ec2-user www   1283 Sep 20 13:38 composer.json
-rw-rw-r--  1 ec2-user www 124068 Sep 22 17:27 composer.lock
drwxrwsr-x  2 ec2-user www   4096 Sep 20 13:38 config
drwxrwsr-x  5 ec2-user www   4096 Sep 20 13:38 database
-rw-rw-r--  1 ec2-user www    556 Sep 20 13:38 gulpfile.js
-rw-rw-r--  1 ec2-user www    400 Sep 20 13:38 package.json
-rw-rw-r--  1 ec2-user www    930 Sep 20 13:38 phpunit.xml
drwxrwsr-x  4 ec2-user www   4096 Sep 20 13:38 public
-rw-rw-r--  1 ec2-user www   1918 Sep 20 13:38 readme.md
drwxrwsr-x  5 ec2-user www   4096 Sep 20 13:38 resources
drwxrwsr-x  2 ec2-user www   4096 Sep 20 13:38 routes
-rw-rw-r--  1 ec2-user www    563 Sep 20 13:38 server.php
drwxrwsr-x  5 ec2-user www   4096 Sep 20 13:38 storage
drwxrwsr-x  2 ec2-user www   4096 Sep 20 13:38 tests
drwxrwsr-x 31 ec2-user www   4096 Sep 22 17:27 vendor

Now if I set permission 777 on /blog/storage, Laravel loads just fine, but I am not sure if this is a good idea.

Why the Apache2 server can't write to /blog/storage with permission 775, while the owner group is www ? Thanks!

Edmond Tamas
  • 3,148
  • 9
  • 44
  • 89
  • Hi, I am currently trying to do exactly the same thing as you did. I've followed @Vijay answer but still not working for me. How did you manage to do it? could you tell me your storage/ permissions including the subfolders? – morgan9999 Aug 29 '17 at 09:18
  • @ariestikto check the owner/group that the "storage" folder belongs to, using: `ls -l`, it should be `ec2-user www `. If not, use: `sudo chmod -R ec2-user:www storage` (from inside your site's directory) to set the user/group. If that fails check if apache has the `www` group by: `groups apache`, if it doesn't add it: `usermod -g www apache`. Hope it helps – Edmond Tamas Aug 29 '17 at 11:44
  • Ah I see, adding apache user to www group do the trick, thanks a lot! – morgan9999 Aug 29 '17 at 13:21
  • Great, I am glad it worked. – Edmond Tamas Aug 29 '17 at 18:39

1 Answers1

1

With 755 permission, owner which is ec2-user in your case will have write permission whereas the group www will have read and execute permission only to that directory.

You can use acl to grant write permissions for user who is running the process instead of granting 777

setfacl -m u:user:rwx /blog/storage

Vijay
  • 56
  • 3