Magento 2 – Huge Permissions Issue

installationmagento2permissions

I'm really hoping someone can help me here. I started with a brand new VPS for Magento2, downloaded it, installed, ran the installer, all was great, except the page took like 5 minutes to load (admin or storefont) and no css/js/images would show. and I finally after about 20 hours, got it to work. What I did was reinstall magento from scratch (about 15 times) – and finally ran:

find . -type d -exec chmod 770 {} \; && find . -type f -exec chmod 660 {} \; && chmod u+x bin/magento

which broke everything, then I ran a permissions 755 on EVERYTHING. and finally I can view the store, and the admin. and seems to function somewhat ok.

Problem is, anything I do on the store, there's continual permissions issues going forward. Example, I upload a logo through the admin, and the logo is a 404 if you try to view it from a browser, until I go in and browse to the pub folder with the images, and change permissions on the logo .png file. (same goes for every product image, every everything)

Certainly there has to be some better way of solving this? so I guess the first part of the question is answered, but now a different issue. About ready to scrap magento, as this is just too time consuming. It should not be this difficult out of the box. I would LOVE any suggestions from anyone, thanks in advance!

Maybe it has something to do with the Magento file system owner stuff in the setup docs? is that something that can be changed after Magento is installed? and could this have anything to do with all these problems?

Best Answer

The official documentation say that you need create user for magento installation and add this user to group of web server.

To fixing perform you need do:

  1. Add you user to web server group (how to find web server group):

    usermod -g [web-server-group] [user]

    for example on ubuntu vagrant box usermod -g www-data vagrant

  2. Recursive change group of files

    sudo chown -R :[web-server-group] [magento_root]

    example sudo chown -R :www-data /vagrant/magento2

Related Topic