Skip to content

Instantly share code, notes, and snippets.

@drazulay
Last active September 20, 2024 19:11
Show Gist options
  • Save drazulay/5c27a03b332dfb68bb736ca37e1e72bc to your computer and use it in GitHub Desktop.
Save drazulay/5c27a03b332dfb68bb736ca37e1e72bc to your computer and use it in GitHub Desktop.
Quickly set up magento2 with redis, amqp and elasticsearch and link the domain in valet-plus.
#! /usr/bin/env bash
if [ ! -f app/etc/env.php ]; then
printf "Installing magento..\n"
php bin/magento setup:install \
--db-host 127.0.0.1 \
--db-name magento2 \
--db-user admin \
--db-password admin123 \
--search-engine elasticsearch7 \
--elasticsearch-host 127.0.0.1 \
--elasticsearch-port 9200 \
--cache-backend redis \
--cache-backend-redis-server 127.0.0.1 \
--cache-backend-redis-db 0 \
--cache-backend-redis-port 6379 \
--cache-id-prefix "cache_" \
--session-save redis \
--session-save-redis-host 127.0.0.1 \
--session-save-redis-port 6379 \
--session-save-redis-timeout 1 \
--session-save-redis-persistent-id e2eae63e177085254f8b65ac648a40705149be1ea9e3b7badb8b61db \
--session-save-redis-db 1 \
--page-cache redis \
--page-cache-redis-server 127.0.0.1 \
--page-cache-redis-db 3 \
--page-cache-redis-port 6379 \
--page-cache-id-prefix "page_" \
--amqp-host 127.0.0.1 \
--amqp-port 5672 \
--amqp-user admin \
--amqp-password admin123 \
--consumers-wait-for-messages 1 \
--allow-parallel-generation \
--enable-debug-logging 1 \
--enable-syslog-logging 1 \
--backend-frontname admin \
--admin-user admin \
--admin-password admin123 \
--admin-email "[email protected]" \
--admin-firstname Admin \
--admin-lastname Admin \
--cleanup-database \
--use-sample-data
printf "Setting base urls..\n"
php bin/magento setup:store-config:set -vvv --base-url="http://magento2.test/"
php bin/magento setup:store-config:set -vvv --base-url-secure="https://magento2.test/"
printf "Disabling two-factor authentication modules..\n"
php bin/magento module:disable Magento_TwoFactorAuth Magento_AdminAdobeImsTwoFactorAuth
printf "Installing sample data..\n"
php bin/magento sampledata:deploy
php bin/magento module:enable Magento_CustomerSampleData Magento_MsrpSampleData Magento_CatalogSampleData Magento_DownloadableSampleData Magento_OfflineShippingSampleData Magento_BundleSampleData Magento_ConfigurableSampleData Magento_ThemeSampleData Magento_ProductLinksSampleData Magento_ReviewSampleData Magento_CatalogRuleSampleData Magento_SwatchesSampleData Magento_GroupedProductSampleData Magento_TaxSampleData Magento_CmsSampleData Magento_SalesRuleSampleData Magento_SalesSampleData Magento_WidgetSampleData Magento_WishlistSampleData
printf "Compiling DI.."
php bin/magento setup:di:compile
printf "Deploying static content.."
php bin/magento setup:static-content:deploy -f -j8
printf "Clearing caches.."
php bin/magento cache:clean
fi
if [ "$(valet links | grep "magento2.test" -c)" == "0" ]; then
printf "Linking valet domain..\n"
valet link --secure -- magento2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment