How to fix errors installing optional sample data in Magento 2

- Fire development, Magento 2

Magento 2 export CLI

Below, we describe the most common errors related to the installation of optional Magento 2 sample data and provide small guides on how to fix them. If you encounter issues installing optional sample data in Magento 2, scroll down the page looking for a possible solution. For more Magento 2 tips, check our Cookbook.

File system permission issues (Exceptions)

You use the Setup Wizard to install Magento 2. The following error displays in the console log when running the sample data installation:

Production mode issues (PHP Fatal error)The reason for these exceptions is hidden in your file system permissions settings. You have to reset file system ownership and permissions. Log in as a user who has root privileges. After that, you can run the Magento 2 sample data installation once again.

You’re currently set for production mode and try to install sample data. However, the magento sampledata:deploy command causes the following error:

There is a simple rule: install sample data in developer mode. You cannot do that in production mode. So log in as the Magento file system owner, switch to developer mode, and clean var directories to reinstall sample data in Magento 2. Use the commands below in the specified order:

Security issues (PHP Fatal Error)

You may also see the following message installing optional sample data for Magento 2:

You can fix this issue by disabling SELinux. Use either or CentOS documentation to find a solution that suits your needs. 

Develop branch issues (class does not exist)

You Magento 2 sample data installation may also be interrupted by the following message:

If you cannot install sample data using the Magento 2 develop branch, rely on the master branch. Enter the following commands to switch to the master branch:

Max_execution_time issues (installation doesn’t finish)

The sample data installation in Magento 2 stops right before the end, you see the following message, and nothing changes for a while:

You’ve exceeded the maximum configured execution time of your PHP scripts. Usually, this value is less than necessary for sample data to be installed.

To solve the issue, log in as a user with root privileges and modify your php.ini file. You should find the max_execution_time setting and increase its value to 600 or more. Note that it is necessary to restore the original setting after the installation.

You can find php.ini with the help of this command:

Modify the value of Loaded Configuration File.

For more information about sample data installation issues, read this article: Errors installing optional sample data.