1

These are the permissions that I have applied to my system in the development mode:

sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
sudo chown -R :www-data .
sudo chmod u+x bin/magento

Are these permissions correct for the development environment? Should I leave it for the production mode should the permissions be different? Do we have to do something else to use production mode?

1 Answer 1

3

Here is a link to the Magento2 documentation for file permissions on development and production environments: https://devdocs.magento.com/guides/v2.3/config-guide/prod/prod_file-sys-perms.html

The permissions do differ between production and development.

Here are other links for the overview of ownership https://devdocs.magento.com/guides/v2.3/install-gde/prereq/file-sys-perms-over.html and command examples based on your server https://devdocs.magento.com/guides/v2.3/install-gde/prereq/file-system-perms.html.

In your example you're adding write privileges to those directories. That's a development environment permission setting. On a production environment (once you have production mode enabled) you're going to want to do something like this find app/code lib pub/static app/etc generated/code generated/metadata var/view_preprocessed \( -type d -or -type f \) -exec chmod g-w {} + && chmod o-rwx app/etc/env.php. If you need to run updates to components or upgrade Magento you'll need up open up the permissions again with this find app/code lib var generated vendor pub/static pub/media app/etc \( -type d -or -type f \) -exec chmod g+w {} + && chmod o+rwx app/etc/env.php.

4
  • I have already checked that part of the manual and I can not understand it, so I ask if someone gives me a summary answer
    – Despotars
    Feb 14, 2019 at 14:07
  • Gotcha, here are other links for the overview of ownership (devdocs.magento.com/guides/v2.3/install-gde/prereq/…) and command examples based on your server (devdocs.magento.com/guides/v2.3/install-gde/prereq/…). This should provide the clarity you're looking for. Based on your example it looks like you're going with the two users as opposed to shared hosting.
    – mlunt
    Feb 14, 2019 at 15:56
  • Yes but I found this page where you can see the orders to give permissions that I put up, and I'm not clear if these are the right ones for production too devdocs.magento.com/guides/v2.3/install-gde/prereq/…
    – Despotars
    Feb 14, 2019 at 16:03
  • Your current example is for development because it's adding write privileges. See the update to my answer with more detail.
    – mlunt
    Feb 14, 2019 at 16:12

Your Answer

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

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