Magento 2.0.18 is the final 2.0.x release. After March 2018, Magento 2.0.x will no longer receive security patches, quality fixes, or documentation updates.
To maintain your site's performance, security, and PCI compliance, upgrade to the latest version of Magento.

Appendix—Magento file system ownership and appendix (legacy)

Overview: Magento file system ownership and appendix (legacy)

This topic is provided for convenience for anyone using Magento Open Source or Magento Commerce versions 2.0.0–2.0.5.

In versions before 2.0.6, Magento explicitly set file system permissions when we created files, such as cache and static view files. Starting with 2.0.6, we do not set permissions explicitly. For more detail about file system ownership and permissions for version 2.0.6 and later, see Overview of ownership and permissions.

Summary of file system permissions

This section summarizes the permissions Magento uses when creating files in the file system.

Developer mode permissions

In developer mode, Magento sets permissions as follows:

  • Directories: 770

    770 permissions give full control to the owner and to the group, and no permissions to anyone else.

  • Files: 660

    660 permissions give read-write permissions to the owner and to the group, and no permissions to anyone else.

Production mode permissions

Changing modes affects permissions and ownership the following subdirectories in your Magento installation:

var/view_preprocessed
var/generation
var/di

When you change to production mode, we set the following permissions on these directories and subdirectories:

  • Directories: 750

    750 permissions give full control to the owner, read and execute permissions to the group, and no permissions to anyone else.

  • Files: 640

    640 permissions give read-write permissions to the owner, read-only permissions to the group, and no permissions to anyone else.

Set permissions before installing the Magento software

Use the following steps:

  1. If you haven’t already done so, log in to your Magento server as, or switch to, the Magento file system owner.
  2. Change to the Magento installation directory:

    cd <web server docroot>/<magento2 base dir>
    

    The base directory is typically a subdirectory named magento2 under your web server’s docroot. Need help locating the docroot? Click here.

    Examples:

    • Ubuntu: /var/www/magento2
    • CentOS: /var/www/html/magento2
  3. Set ownership:

    chown -R :<your web server group name> .
    

    Typical examples:

    • CentOS: chown -R :apache .
    • Ubuntu: chown -R :www-data .
  4. Set permissions:

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

    If you must enter the commands as sudo, use:

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