How to solve magento2 permission issues

akbaralmansoor placeholder

After installing Magento 2.x, sometimes frontend and admin side js, CSS, and images can not load properly. This problem occurs because of file permission issues.

Though Magento 2 recommends setting ownership of all files & folders to the web server group, sometimes this is not possible due to some reasons. For example on shared hosting, the developer can not change ownership of files & folders.

To overcome this problem, we need to set permission 755 to each directory (Magento recommends 700) and we need to set permission 644 to each file (Magento recommends 600).

In /vendor/magento/framework/Filesystem/DriverInterface.php ,

Change line number 20 from

const WRITEABLE_DIRECTORY_MODE = 0770;

To

const WRITEABLE_DIRECTORY_MODE = 0755;

Also, change the line no 25 from

const WRITEABLE_FILE_MODE = 0660;

To

const WRITEABLE_FILE_MODE = 0644;

After the above change, replace the pub/static folder with a new fresh copy. And now refresh your front page or admin page.


Leave a Reply