How to handle the file permission in Magento 2(Shared Hosting)

In Magento 2 Permission is very essential. In this article, I will explain you how to manage the permission in the Developer mode and Production Mode in Magento 2

In the Magento 2 hosting, it commonly has two types: Shared hosting and Private hosting. Here in this, we will talk about the shared hosting.

Usually, shared hosting offers to allow you to log in to the server as one user. The user may log in, then they may transfer files using FTP, and this user also runs the web server.

  1. Set up an one user for default or developer mode

The below-mentioned directories should be writable by the user in default or developer mode:

File Permission In Magento 2

By your shared hosting provider, you may set this permission using the command line or a file manager application offered.

  1. Set up one user for production mode

You must Remove write access from files in the following directories for improved security, When you’re set to organize your site to production:

File Permission In Magento 2

To update an elements, install new components, or upgrade Magento software, all of the previous directories should be read-write

To eliminate writable permissions to files and directories from the web server user’s group:

  1. You may log in to your Magento server.
  2. Then you may modify to your Magento installation directory.
  3. You may enter the following command to modify to production mode:
  4. php bin/magento deploy:mode:set production
  5. You may type the following commands:
  6. Get var vendor pub/static app/etc var/generation var/di var/view_preprocessed -type f -exec chmod u-w {} \;
  7. find var vendor pub/static app/etc var/generation var/di var/view_preprocessed -type d -exec chmod u-w {} \;
  8. chmod o-rwx app/etc/env.php
  9. chmod u+x bin/magento

You may alternately type all the previous commands as one command:

Find  pub/static app/etc var/generation var/di var/view_preprocessed -type f -exec chmod u-w {} \; && find pub/static app/etc var/generation var/di var/view_preprocessed -type d -exec chmod u-w {} \; && chmod o-rwx app/etc/env.php && chmod u+x bin/magento

Create files and directories writable

To create the files and directories writable so you can update components and upgrade the Magento software:

  1. Log in to your Magento server.
  2. Modify to your Magento installation directory.
  3. Type the following commands
  4. chmod -R u+w

Related:

Last Update: February 27, 2019  

March 20, 2018   470   Nandini R    Operations    
Total 1 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook
Twitter
INSTAGRAM
LinkedIn