Fabrizio Vanzani

ecommerce development, magento and tech tips

Install Magento 2 with warden dev env

Prerequisites

OrbStack or DockerDesktop

Start docker and warden

Start OrbStack

warden svc up

Configure warden env file

mkdir demo-m2
cd demo-m2
warden env-init demo-m2 magento2

Edit .env for further configuration , example:

WARDEN_RABBITMQ=0

Run warden environment

warden env up

certificates

warden sign-certificate demo-m2.test

install magento with composer

warden shell

Prepare composer credentials:

PubKey=...
PriKey=...
composer --global  config http-basic.repo.magento.com $PubKey $PriKey

Install magento packages:

META_PACKAGE=magento/project-community-edition
META_VERSION=2.4.6-p3
 composer create-project --repository-url=https://repo.magento.com/ \
     "${META_PACKAGE}" /tmp/exampleproject "${META_VERSION}"

Install latest magento packages:

composer create-project --repository-url=https://repo.magento.com/  "${META_PACKAGE}" /tmp/exampleproject

Sync files from tmp dir to project dir:

rsync -a /tmp/exampleproject/ /var/www/html/
rm -rf /tmp/exampleproject/
bin/magento setup:install \
     --backend-frontname=backend \
     --db-host=db \
     --db-name=magento \
     --db-user=magento \
     --db-password=magento \
     --search-engine=opensearch \
     --opensearch-host=opensearch \
     --opensearch-port=9200 \
     --opensearch-index-prefix=magento2 \
     --opensearch-enable-auth=0 \
     --opensearch-timeout=15 \
     --http-cache-hosts=varnish:80 \
     --session-save=redis \
     --session-save-redis-host=redis \
     --session-save-redis-port=6379 \
     --session-save-redis-db=2 \
     --session-save-redis-max-concurrency=20 \
     --cache-backend=redis \
     --cache-backend-redis-server=redis \
     --cache-backend-redis-db=0 \
     --cache-backend-redis-port=6379 \
     --page-cache=redis \
     --page-cache-redis-server=redis \
     --page-cache-redis-db=1 \
     --page-cache-redis-port=6379 \
     --disable-modules='Magento_TwoFactorAuth,Magento_Elasticsearch7'  \
     --magento-init-params='MAGE_MODE=developer' \
     --admin-firstname=Magento \
     --admin-lastname=User  \
     --admin-email="magento@example.com" \
     --admin-user=magento \
     --admin-password=magento1234 \
     --cleanup-database 

If rabbitmq installed:

     --amqp-host=rabbitmq \
     --amqp-port=5672 \
     --amqp-user=guest \
     --amqp-password=guest \

Configure Application:

bin/magento config:set --lock-env web/unsecure/base_url \
     "https://${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}/"
 bin/magento config:set --lock-env web/secure/base_url \
     "https://${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}/"
 bin/magento config:set --lock-env web/secure/offloader_header X-Forwarded-Proto
 bin/magento config:set --lock-env web/secure/use_in_frontend 1
 bin/magento config:set --lock-env web/secure/use_in_adminhtml 1
 bin/magento config:set --lock-env web/seo/use_rewrites 1
 bin/magento config:set --lock-env system/full_page_cache/caching_application 2
 bin/magento config:set --lock-env system/full_page_cache/ttl 604800
 bin/magento config:set --lock-env catalog/search/enable_eav_indexer 1
 bin/magento config:set --lock-env dev/static/sign 0
 bin/magento deploy:mode:set -s developer
 bin/magento cache:disable block_html full_page

warden useful aliases

Aliases on host machine:
https://github.com/MagePsycho/magento2-warden-aliases/

utility: install adminer

warden shell
cd pub
wget http://www.adminer.org/latest.php -O adminer.php 

Point to: https://app.demo-m2.test/adminer.php


Posted

in

, ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *