Follow Us :
Magento2 issues after installing

Permissions issue after installing Magento2 via composer? How to Fix it?

Facebook
Twitter
LinkedIn
WhatsApp

Starting from Magento 2.4.2, the command line is the default way to install Magento. You can download the archive versions of Magento that you can install. However, it is strongly recommended that you use the Composer to download Magento instead. There are various benefits of using this method. Some of them are listed below:

• You can use Magento in the production environment
• It allows you to reuse third-party libraries without combining them with source code
• It manages dependencies to reduce extension conflicts and compatibility issues
• It supports the PHP Framework standard
• Repackage Magento Open Source with other components

While installing Magento you may encounter installation problems. You might have read/write limitations. You need to set the permissions after installing Magento2. If you get a ‘permission denied’ error.
The above is a screenshot of the error that you might get. Here are set of commands that you need to execute for resolving permissions issue. You may also need to use SUDO to run these commands.

Try the following command first:

Here are set of commands that you need to execute for resolving permissions issue. You may also need to use SUDO to run these commands.

Magento Command1
find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 644 {} \; && chmod u+x bin/magento
If you still face any issues, you can try the following commands.
Magento Command1
find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 644 {} \; && chmod u+x bin/magento

1. Change the permissions for folders named as var, pub and generated to 777 (read, write, and execute)

chmod -R 0777 var/ pub/ generated/

2. Use this command to clear all generate files in Magento 2 command line

command

rm -rf var/cache/* var/view_preprocessed/* generated/* pub/static/*

3. Use the following command to update the database schema. By default, magento setup:upgrade clears compiled code and the cache. We need to use magento setup:upgrade to update all the components.

php bin/magento setup:upgrade

4. The following command setup:di:compile command generates the contents of the var/di folder in Magento. If you do any code change especially with factory methods, proxy, add plugins or any code compilation; you must run this command to avoid any kind of fatal errors.

php bin/magento setup:di:compile

5. Run this command to enable static view files deployment.

php bin/magento setup:static-content:deploy –f

6. Run this command to flush all the management cache.

php bin/magento cache:flush

7. Run this command to reindex in magento 2.

php bin/magento indexer:reindex

8. Change the file permissions on a local install.
Upgrade Command

chmod -R 0777 var/ pub/ generated/

This will help you resolve permissions errors after installing Magento2.

Get Our Latest Tips & Tricks Updated