Magento – Magento 2: Installing with Redis by Default

bin-magentoinstallationmagento2redis

Magento 2's CLI has a setup:install command that will let you generate an initial configuration

php bin/magento setup:install --admin-email astorm@example.com --admin-firstname Alan --admin-lastname Storm --admin-password 'whymagentowhy?@###@' --admin-user username --backend-frontname admin.bak --base-url http://magento.example.com --db-host 127.0.0.1 --db-name db_name --db-password yeahright --db-user notroot --session-save files --use-rewrites 1 --use-secure 0 -vvv

Is there [a version of this command, another command, or some third party project] that will automatically generate the needed configuration nodes for a redis cache and redis sessions?

Best Answer

I just have starter env file what i copy to 'app/etc/env.php' before running the installer command:

<?php
return array(
    'session' =>
        array(
            'save' => 'redis',
            'redis' =>
                array(
                    'host' => '127.0.0.1',
                    'port' => '6379',
                    'password' => '',
                    'timeout' => '2.5',
                    'persistent_identifier' => '',
                    'database' => '0',
                    'compression_threshold' => '2048',
                    'compression_library' => 'gzip',
                    'log_level' => '1',
                    'max_concurrency' => '6',
                    'break_after_frontend' => '5',
                    'break_after_adminhtml' => '30',
                    'first_lifetime' => '600',
                    'bot_first_lifetime' => '60',
                    'bot_lifetime' => '7200',
                    'disable_locking' => '0',
                    'min_lifetime' => '60',
                    'max_lifetime' => '2592000',
                ),
        ),
    'cache' =>
        array(
            'frontend' =>
                array(
                    'default' =>
                        array(
                            'backend' => 'Cm_Cache_Backend_Redis',
                            'backend_options' =>
                                array(
                                    'server' => '127.0.0.1',
                                    'port' => '6379',
                                    'database' => '1',
                                ),
                        ),
                    'page_cache' =>
                        array(
                            'backend' => 'Cm_Cache_Backend_Redis',
                            'backend_options' =>
                                array(
                                    'server' => '127.0.0.1',
                                    'port' => '6379',
                                    'database' => '1',
                                    'compress_data' => '0',
                                ),
                        ),
                ),
        )
);

The install shouldn't replace anything from the env.php if you don't tell it to.

Related Topic