The article explains how to install sample datas AFTER Magento 2 installation.
If you want to do it BEFORE, show the Magento official documentation.
During the web setup wizard, you can check “Install Sample Datas” box
With Magento 2.1
Go inside the Magento 2 parent folder :
cd /var/www
Make a git clone of the sample datas repository, specificy the same branch of the Magento 2 installation for the “-b” paramater :
git clone -b 2.1 https://github.com/magento/magento2-sample-data.git
aunch the following script :
php -f /var/www/magento2-sample-data/dev/tools/build-sample-data.php -- --ce-source="/var/www/magento2"
Make a Magento upgrade :
./bin/magento setup:upgrade
Change the sample datas owner :
cd /var/www/magento2-sample-data sudo chown -R :www-data .
If you have some problems with file permissions, run these commands :
cd /var/www/magento2 sudo chown -R :www-data . sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento; sudo chmod -R g+w /var/www/magento2/{pub,var}
Be careful, Magento 2 sample datas are linked inside the Magento 2 with symbolic links, don’t remove the folder magento2-sample-data 🙂
With Magento 2.0
Go inside your Magento 2 folder, for me it’s :
cd /var/www/magento2
And launch the command :
./bin/magento sampledata:deploy
If you have a message like :
The 'https://repo.magento.com/packages.json' URL required authentication. You must be using the interactive console to authenticate
Launch the command composer update
, you will have a prompt :
Authentication required (repo.magento.com): Username:
Go on the Magento website, create an account. Sign in and go on “Developper > Secure Keys” section. Create a new key – I named it “magento 2 – the public key will be the username, and the pricate key, the password. Put these keys on your shell prompt and continue the installation.
Wait until the end of the composer update.
If you don’t need to put your login and password, you can continue this article.
You will have a file in /home/<USER>/.composer/auth.json, take it’s content, and put it on the file
/var/www/magento2/var/composer_home/auth.json
Relaunch the command :
./bin/magento sampledata:deploy
And the deployment will finish.
Result
Go on your magento 2 website and you will see that :
If not :
– Have you disable caches ? Disable or flush its
– Does your folder “pub/media” and it’s subfolders are writeable ?
– Run the command : bin/magento setup:upgrade
what happened to me was everything was in place, caches flushed & folders writable but all sample data modules were disabled by default.
had to run module:status to find out, then ./bin/magento –all module:enable
only after that sample data finally appeared.
Best Comment Ever!! Thank you, man. And autor, thank`s for lessons!
Thanks for this tutorial , but I had issue following it. Thankfully I found a very good tutorial for installing Magento 2 sample data on Magenticians, do check it, because its really easy to follow