Skip to main content
Magento 2

Magento 2 – Useful Commands

By May 10, 2016June 2nd, 2016One Comment

Useful Magento 2 Commands via SSH / CMD

Here are a few Magento 2 commands that I’ve found useful when setting up a Magento 2 install and running migration tools.

To use these commands you’ll need to have SSH access to your server or use the Command Line for local access. These commands are run within the /magento2 folder and reference the /magento2/bin folder.

Move to /magento2 path

cd /FullServerPath/www/magento2

 

ReIndex

php bin/magento indexer:reindex

 

Flush Cache

php bin/magento cache:flush

 

Deploy Static Files – GB version

php bin/magento setup:static-content:deploy en_GB

 

View your Magento version

php bin/magento –version

 

View installed modules

php bin/magento module:status

 

Disable a module (Weee used as an example)

php bin/magento module:disable Magento_Weee

 

Uninstall Magento

php bin/magento setup:uninstall

 

Install Magento – GB Settings

php bin/magento setup:install –backend-frontname=ADMINLINK –session-save=files –db-host=localhost –db-name=DATABASENAME –db-user=DATABASEUSER –db-password=DATABASEPASSWORD –base-url=URL –admin-user=ADMINUSER –admin-password=ADMINPASSWORD –admin-email=EMAILADDRESS –admin-firstname=John –admin-lastname=Smith –language=en_GB –currency=GBP –timezone=Europe/London

 

Magento Data Migration Tool

To run the migration tool commands you’ll need to set up your own config.xml and map.xml files, from the .xml.dist files of your Magento 1.x version.

Migrate settings

php bin/magento migrate:settings vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.2/config.xml

Migrate data

php bin/magento migrate:data vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.2/config.xml

Reset tool – so previous steps are reverted

php bin/magento migrate:data vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.2/config.xml –reset

 

Ubertheme Data Migration Tool Steps

php bin/magento module:enable –clear-static-content Ubertheme_Ubdatamigration

php bin/magento setup:upgrade

php bin/magento setup:di:compile

 

Composer Commands

I run larger scripts locally, before moving the updated composer.lock file to the production server. My server requires the prefix ‘php composer.phar’ where locally I just need ‘composer’.

 

Check Composer is installed and show the version

composer -V

 

Magento Data Migration Tool – Add to project

composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool

composer require magento/data-migration-tool:2.0.5

 

Ubertheme Data Migration Tool – Add to project

composer require ubertheme/module-ubdatamigration

 

Get newer versions of all required modules (use with caution)

composer update

 

Get newer version of a module

composer update magento/data-migration-tool

 

Get required modules (safer than update)

composer install

 

I hope you find these of use, Magento’s official documentation can be a bit difficult to reference at times.

Andrew Taylor

A senior UI designer with over 25 years of web design and web development experience working for some of the largest companies in the UK. An expert in all things Magento and WordPress.

One Comment

  • James Smith says:

    Excellent Article!! This is gonna be useful to me and many other developers who are now diving into Magento 2.0
    Thank a lot Andrew. Our Magento 2 is installed on a shared web hosting and hence cheap 😀

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.