3

Suppose user-a run the command php magento setup:di:compile, it generated cache file with wrong user group, the wrong user group is user-a(the primary group of user-a), in fact it should be apache(the apache group in CentOS), then it will result file permission error when visit website in browser.

I had set the SetGID, most files generated with right user group(apache), only the files in var/cache/mage-tags folder has wrong user group(user-a), so I have to set its group manually every time, anyone has better way to solve the problem? Thanks.

2
  • 1
    I have exactly this same problem. The approach of two users as described on devdocs.magento.com/guides/v2.1/install-gde/prereq/… just plain doesn't work! As soon as I compile DI with the Magento system owner ("magento_user"), var/cache/* folders lose their set-gid bits, and var/cache/mage-tags/* folders are created with magento_user's primary group and 660 permissions, and the web user (www-data) fails opening the site because it cannot access this content. Oct 31, 2017 at 14:04
  • @JānisElmeris Yes, exactly the same problem.
    – Key Shang
    Nov 1, 2017 at 2:26

1 Answer 1

2

Run magento command with web server user will solve a lot of permission problems or potential problems.

sudo -u apache php magento setup:upgrade
sudo -u apache php magento setup:di:compile

Run the cron jobs also under the web server user

sudo -u apache crontab -e

apache is the web server user in CentOS.

The default web server user of Ubuntu is www-data.

5
  • 1
    I would see this as a work-around. As the whole point (or much of it, at least) of having two-user set-up is exactly to run console commands with one, and serve web content with the other. Quotes from devdocs.magento.com/guides/v2.1/install-gde/prereq/… (Set ownership and permissions for two users): "Magento file system owner is another term for the command-line user.", "In this type of setup, you typically cannot log in as, or switch to, the web server user. You typically log in as one user and run the web server as a different user." Oct 31, 2017 at 13:57
  • @JānisElmeris Yes, it is just a work-around. Another way is change the user primary group as apache, but it is not secure. The better way is official Magento fix the compile problem.
    – Spices
    Nov 1, 2017 at 1:45
  • Reported in their issue tracker: github.com/magento/magento2/issues/11930 Nov 1, 2017 at 12:20
  • @JānisElmeris My English is not very well, thanks for your issue report, I had go to thumb up the report.
    – Key Shang
    Nov 6, 2017 at 1:58
  • By Magento team in that issue: "The fix will be available with the upcoming 2.2.5 release." Mar 27, 2018 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.