WE'RE CLOSED TO CELEBRATE OUR HUNG KINGS COMMEMORATION DAY! WE WILL COME BACK SOON!

Cart

5 Most Common Magento 2 Installation Errors & How to Fix Them

5 Most Common Magento 2 Installation Errors & How to Fix Them

The most popular Magento 2 Installation Errors are collected in this article and including short recommendations on how to fix them. Whether you’re having trouble installing sample data in Magento 2 themes, go through this article to see if there’s a solution.

1. Installation Progress Has Stopped

Problem: Once through the Magento Setup Wizard, installation might become stopped right before the end, with no error notice appearing.

Solution: Your PHP scripts’ maximum execution time has been exceeded. This value is usually lower than what is required to install sample data. You may just need to change the PHP max execution time setting to solve this problem in file max_execution_time.

  • To find php.ini, use the phpinfo.php file.
  • Open the php.ini file in text editor (note: you must be a user with root access to accomplish this).
  • Change the value of the max execution time option to 18000.
  • Close the text editor after saving your changes.
  • Restart Apache

If you’re using nginx, you’ll also need to add a timeout setting to the location ~ ^/setup/index.php of your nginx host configuration file:

location ~ ^/setup/index.php {

    .....................

    fastcgi_read_timeout 600s;

       fastcgi_connect_timeout 600s;

}

Restart nginx

If you’re using Varnish, you’ll need to add a timeout limit value in the backend section of your default.vcl file:

backend default {

.....................

      .first_byte_timeout = 600s;

}

Restart Varnish

2. Fatal PDO Error

Problem: You may receive a PDO error message like this:

PHP Fatal error:  Class 'PDO' not found in /var/www/html/magento2/setup/module/Magento/Setup/src/Module/Setup/ConnectionFactory.php on line 44

Solution: The most likely reason of this issue is because you haven’t installed one or more of the PHP extensions listed below, which are all required. If any of the needed extensions are missing, install them and try again:

  • bcmath (Magento 2 Commerce only)
  • devel (both Commerce and Open Source)
  • gd (both Commerce and Open Source)
  • iconv (both Commerce and Open Source)
  • intl (both Commerce and Open Source)
  • json (both Commerce and Open Source)
  • mbstring (both Commerce and Open Source)
  • mysql (both Commerce and Open Source)
  • mysqlnd (both Commerce and Open Source)
  • opcache (both Commerce and Open Source)
  • pdo (both Commerce and Open Source)
  • soap (both Commerce and Open Source)
  • xml (both Commerce and Open Source)

3. Reflection Exception Error

Problem: During installation, you may see the following error message:

[ERROR] exception 'ReflectionException' with message 'Class Magento\Framework\StoreManagerInterface does not exist' in //lib/internal/Magento/Framework/Code/Reader/ClassReader.php

Solution: To resolve this issue, you’ll need to clear the folders and files in Magento’s var subdirectory, and then reinstall Magento. To do so, use the following commands (you’ll need root permission on your Magento file system):

$ cd /var

$ rm -rf var/cache/* di/* generation/* page_cache/*

If you’re still getting the Reflection Exception problem while you’re using Redis, try clearing your Redis cache with this command:

$ redis-cli FLUSHALL

4. Composer Version Error

Problem: During installation, they will generate the following error:

[ErrorException]

  file_get_contents(app/etc/NonComposerComponentRegistration.php): failed to open stream: No such file or directory

Solution: This bug relates to the versions of Composer that were released between November 21 to 26, 2015. To fix this problem, downgrade Composer to a version released before November 21, 2015, or upgrade to a version released after November 26, 2015 and download Magento again.

To validate the version of Composer you’re running, use this command (the date of your Composer release will be given at the bottom of the response):

composer -v

Use the following command to downgrade your Composer version:

composer self-update 1.0.0-alpha11

Use this command to upgrade to the latest version of Composer:

composer self-update

Then, delete your Magento 2 directory and sub-directories and download Magento again.

5. Errors Installing Optional Sample Data

Installing optional sample data helps you to get a sense for Magento before diving into the process of really building your business. However, there are a variety of issues that can occur while installing optional sample data, including:

5.1. Permissions Error

This error is caused by your file system permissions settings (from Magento Help Center):

Module 'Magento_CatalogRuleSampleData':
[ERROR] exception 'Magento\Framework\Exception\LocalizedException' with message 'Can't create directory /var/www/html/magento2/generated/code/Magento/CatalogRule/Model/.' in /var/www/html/magento2/lib/internal/Magento/Framework/Code/Generator.php:103

(more)`

Next exception 'ReflectionException' with message 'Class Magento\CatalogRule\Model\RuleFactory does not exist' in /var/www/html/magento2/lib/internal/Magento/Framework/Code/Reader/ClassReader.php:29

(more)

Solution: Go back and set up your access permissions as a user with root privileges.

5.2. Production Mode Error

If you try to install optional sample data in production mode with Composer, you’ll get the following error (from Firebear Studio):

PHP Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Console\Input\ArrayInput::__construct() must be of the type array, object given, called in //vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 97 and defined in //vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php:37

Solution: Instead of installing the optional sample data in development mode, you’ll need to install it in developer mode to avoid this problem. Log in as the owner of the Magento file system and run the following commands:

cd <magento_root>

bin/magento deploy:mode:set developer

rm -rf generated/code/* generated/metadata/*

bin/magento sampledata:deploy

5.3. SELinux Error

This error is caused by SELinux:

PHP Fatal error: Call to undefined method Magento\Catalog\Model\Resource\Product\Interceptor::getWriteConnection() in /var/www/magento2/app/code/Magento/SampleData/Module/Catalog/Setup/Product/Gallery.php on line 144

Solution: To fix this error, you must disable SELinux. Check out this guide from TecMint for detailed instructions on disabling SELinux.

5.4. Develop Branch Error

Finally, while installing optional sample data, you may see the following error:

[Magento\Setup\SampleDataException] Error during sample https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/dev_downgrade.htmldata installation: Class Magento\Sales\Model\Service\OrderFactory does not exist

Solution: This is a known problem with the Magento 2 develop branch. You can solve this by running the following command to switch to the master branch:

cd <magento_root>

git checkout master

git pull origin master

In conclusion, installing Magento 2 is a essential step for any eCommerce organization! As you can see, Magento 2 installation may provide a number of unexpected issues. But you have answers for these concerns as well, which may help you obtain unlimited benefits from Magento 2, and you’re set to go as long as you have a team of specialists to aid and patch things up.

You can refer choosing the latest Magento 2.4.4 themes for your eCommerce business that will save your time and effort of getting installation issues.


Best Magento 2.4.4 Themes

Related Post

Leave a Reply

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