Skip to content

Instantly share code, notes, and snippets.

@killpond
Last active August 13, 2018 11:24
Show Gist options
  • Save killpond/d97b73daba24cf2598301136e021d011 to your computer and use it in GitHub Desktop.
Save killpond/d97b73daba24cf2598301136e021d011 to your computer and use it in GitHub Desktop.
Useful Magento 2 commands when doing development

A list of useful Magento 2 commands to help with development

Maximise the session life time value

php bin/magento config:set admin/security/session_lifetime 31536000

Create admin account

php bin/magento admin:user:create --admin-user='user' --admin-password='password' --admin-email='[email protected]' --admin-firstname='user' --admin-lastname='user'

Change base URLs

php bin/magento config:set --scope=website --scope-code=base -- web/unsecure/base_url "http://www.website.com/"
php bin/magento config:set --scope=website --scope-code=base -- web/secure/base_url "http://www.website.com/"

Generate a Varnish VCL file

Does not care about nor effect the admin settings!

php bin/magento varnish:vcl:generate --access-list=localhost --backend-host=localhost --backend-port=8080 --export-version=5 --output-file=varnish.vcl

Set Varnish settings

php bin/magento config:set system/full_page_cache/caching_application 2
php bin/magento config:set system/full_page_cache/varnish/access_list localhost
php bin/magento config:set system/full_page_cache/varnish/backend_host localhost
php bin/magento config:set system/full_page_cache/varnish/backend_port 8080

Enabled Redis

Must connect or it will not save the settings!

php bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=127.0.0.1 --cache-backend-redis-port=6379
php bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=127.0.0.1 --page-cache-redis-port=6380
php bin/magento setup:config:set --session-save=redis --session-save-redis-host=127.0.0.1 --session-save-redis-port=6381

OR use this for socket based Redis https://gist.github.com/PeteZero1/f40ca3bda6a2e43bf13a09103de1b01c

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