Magento 2 File Permissions Issue

The most common question that Magento users ask is the right permissions. Whether you run your business in single or multi-user mode differs and can also be different in different modes.

The owner of the Magento file system is called the user who can own and write files to the Magento file system. The owner of the Magento file system is sometimes referred to as the command line user.

Each owner has different permissions to read / write files to prevent problems from unauthorized people or processes that could damage your system. Before installing Magento 2, you need to set read and write permissions for the web server group.

This is necessary so that the installation wizard or the command line can write files to the Magento file system.

Normally, when you run a script / file without permissions, you will get an error saying that you have denied bash permissions. All you need to do is change the file permissions and add executable permissions.

Magento 2 file system permissions

When you create a file or directory in Magento, you grant the default permission set. However, the default settings can pose a security risk to your personal data. For example, if a text file has 777 permissions, everyone gets read, write, and execute permissions. The 777 shown in the example is umask (this function is used to determine file permissions for newly created files and folders, usually represented by a symbol or octal value) or user. It is called a mask in the creation mode mask.

You also want your Magento installation to be secure in the development environment. Below are some guidelines on file system ownership and permissions to help prevent problems from unauthorized people or processes that could harm your system.

As the owner of the Magento file system, we mean the user who owns the Magento system files and can write to them.

The owner of the Magento file system is sometimes referred to as the command line user.

File permissions Issues
  • File permissions readiness check issues
  • File Permission Check
  • File permission not met etc…
The important things:
  • Magento File System Owner: You need to have full control (read / write / execute) over all files and folders.
  • Must not be a web server user. Must be another user.
  • The web server user must have access to write the following files and folders:

var

app/etc

pub

(and probably new in 2.2.1:) generated

  • Web server groups also require a Magento file system so that Magento users (who are in the group) can share files with web server users. (This includes files created by Magento Admin or other web-based tools.)
  • We recommend setting the permissions as follows:

All directories have 755 permissions.

755 permissions give full control (that is, read/write/execute) to the owner and read and execute permissions to the group and other.

All files have 664 permissions.

664 permissions mean the owner and the group can read and write but other users have only read permissions.

You should set it as below recommended.

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

Leave A Comment