Is there a way to activate the Varnish use using the command line, not the admin interface? In the bin/magento comand line tool there are options for cache but nothing specific for Varnish.

I am building an Ansible script that automatizes the installation and configuration of the M2EE and this step seems that has to be done manually (which I did and works well). I would prefer a command line action than changed direct values in the mySql, but maybe you have other suggestions.

  • I believe your question is answered, could you tick the one you like the most? thanks – Savvas Radevic Feb 14 at 12:12


php bin/magento config:set system/full_page_cache/caching_application 2

And follow the same patterns for the other paths, like so:

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
  • is this system/full_page_cache/caching_application value 1 or 2 for varnish? Because in my magento installation, it seems to be 2 for varnish – Savvas Radevic Feb 14 at 11:55

How about adding mysql script.sql with the following contents:

insert into core_config_data(scope,scope_id,path,value) values ('default',0,'system/full_page_cache/caching_application',2), ('default',0,'system/full_page_cache/varnish/access_list','localhost'), ('default',0,'system/full_page_cache/varnish/backend_host','localhost'),('default',0,'system/full_page_cache/varnish/backend_port','8080');

You can change localhost and 8080 to your varnish settings.

  • thanks, as I said I would consider this my second option, as I see it "hackish" - because it modifies directly values in the db and overpassing whatever business logic M2 may have when doing the proper activation. – Elzo Valugi Mar 29 '17 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.