Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Created July 11, 2017 02:20
Show Gist options
  • Save molotovbliss/866d889e76d206c66a127d4227382a6b to your computer and use it in GitHub Desktop.
Save molotovbliss/866d889e76d206c66a127d4227382a6b to your computer and use it in GitHub Desktop.
M2 CLI Commands Snippets

QUICK SNIPPETS FOR M2


INSTALL M2

php -f bin/magento setup:install --base-url=http://example.com/ --backend-frontname=admin --db-host=localhost --db-name=magento --db-user=magento --db-password=password123 --admin-firstname=Magento --admin-lastname=User --admin-email=me@example.com --admin-user=admin --admin-password=dbpass321 --language=en_US --currency=USD --timezone=America/Los_Angeles --use-rewrites=1

CRON JOBS: (under web server user/group)

*/1 * * * * /usr/bin/php /var/www/example.com/current/bin/magento cron:run >> /var/www/example.com/current/var/log/cron.run.log &
*/1 * * * * /usr/bin/php /var/www/example.com/current/update/cron.php >> /var/www/example.com/current/var/log/cron.php.log &
*/1 * * * * /usr/bin/php /var/www/example.com/current/bin/magento setup:cron:run >> /var/www/example.com/current/var/log/setup.cron.run.log &

HOW TO: Install an M2 extension/module via composer

composer require amzn/amazon-payments-magento-2-plugin:^1.1.0

Enable the extension:

php bin/magento module:enable Amazon_Core Amazon_Login Amazon_Payment

Upgrade the Magento instalation:

php bin/magento setup:upgrade

Follow any advice the upgrade routine provides; Deploy static content:

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

yy_YY where xx_XX, yy_YY, ... are the locales you are aiming to support


Setup & install node.js LTS on ubuntu server (only needed once)

sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install nodejs

Usual f@#$ing suspects

run all usual suspects inline

php bin/magento setup:upgrade; php bin/magento setup:di:compile; php bin/magento setup:static-content:deploy;

Set deploy mode, also found else where (.htaccess,/etc/)

deploy:mode:set developer deploy:mode:set production

make sure lessc is executable causes

chmod +x vendor/oyejorge/less.php/bin/lessc

install grunt cli

npm install -g grunt-cli

execute grunt scripts /Gruntfile.js

grunt less:templatename grunt exec:templatename

Disable/Enable Maintenance mode

maintenance:disable maintenance:enable


Install elasticserach 2.4

Install latest 2.x via .deb package for ubuntu

wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list

Install via apt sudo apt update;sudo apt install elasticsearch

edit /etc/elasticsearch/elasticsearch.yml add to memory section index.query.bool.max_clause_count: 10024

NOT starting elasticsearch by default on bootup, please execute

sudo update-rc.d elasticsearch defaults 95 10

In order to start elasticsearch, execute

sudo /etc/init.d/elasticsearch start

To test it all worked:

curl http://localhost:9200

Should return some JSON Object including the version number


How-to Switch to production mode

bin/magento setup:static-content:deploy
bin/magento setup:di:compile
bin/magento deploy:mode:set -s production
bin/magento index:reindex
bin/magento cache:flush

BUILD NOTES ln -sfT target link


Fix blank categories: UPDATE catalog_category_entity_varchar SET value='2columns-left' WHERE value = 'category_two_columns_left' SELECT * FROM catalog_category_entity_varchar WHERE value = 'category_two_columns_left'


Install Data Migration

composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool
composer require magento/data-migration-tool:<version>

REFERENCES

m2 provisioning scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment