read

Inspired by Karen from ShipperHQ I have been working on a series to provide a framework for getting a Magento 2 site up and running fast, starting from scratch.

Preface

If you are in a hurry needing to set up an online store you are most likely better off choosing a SaaS platform (like BigCommerce or Shopify). If you are proceeding beyond I assume you have a good reason to pick Magento 2, be it that there is no local support where you are or you need a crucial piece of functionality that you would only be able to provide through Magento 2 (with or without additional existing extensions).

80:20

I am going to opensource some tools which I have been working on for our internal needs. Normally I would have waited and refined them before offering them to anyone but in these times expediency wins over perfect.

I will be including a few things which I believe will make your experience working with Magento 2 better:

  1. a live site and a staging environment which use the same code base. The staging environment allows you to test and trial out any changes before doing the same to your live site
  2. an automated deploy process with some tests that are being run automatically to confirm the site is working as intended
  3. tools to simplify some common tasks

All of the above are intended for us to be able to move forward quickly in the weeks ahead. Allowing you for example to work on your site without needing to impede your live site.

Technical side

I am mostly a developer so will focus on the technical aspects of getting an online store up and running. The below are likely going to be even bigger challenges (happy to add a link to a good resource if you know of one).

  1. Marketing
    how will you get customers to come to your site. Here is just one summary provided by Divante.
  2. Operations
    how will you fulfill any incoming orders with various degrees of physical distancing measures possible in your area. Could you fulfill orders with everyone working from home? What about returns? For example, if you are in New Zealand, the government just clarified that Couriers would also only be able to only deliver essential items.

Prerequisites

  1. a working credit card - we will be incurring some costs along the way. The base assumption is that this store will not be having high order volumes to start with and any vendor choices are done with an eye on affordability.
  2. some understanding of web technologies

Standing on the shoulders of giants

This post is bringing together the great work of others in the Magento ecosystem and beyond. A shoutout to some projects without this would not have been possible:

Support

I am happy to assist anyone working through this guide. The best way to do this is by communicating via creating a public issue here to start with.

Part 1 - Creating Accounts

Useful links for Part 1

Part 2 - Finishing Deploys and Domain Setup

Useful commands for Part 2

Staging

Copy settings file

cp stage.m2-in-a-hurry.com/app/etc/env.php staging/shared/app/etc/env.php

Change document root to our deployed code

cd stage.m2-in-a-hurry.com/
unlink html
ln -s ../staging/current/pub/ html

Change Domain name for Staging Environment

cd ~/staging/current
bin/magento config:set --lock-env web/unsecure/base_url https://stage.m2-in-a-hurry.com/
bin/magento config:set --lock-env web/secure/base_url https://stage.m2-in-a-hurry.com/
bin/magento cache:clean

Production

Copy settings file

cp m2-in-a-hurry.com/app/etc/env.php production/shared/app/etc/env.php

Change document root to our deployed code

cd m2-in-a-hurry.com/
unlink html
ln -s ../production/current/pub/ html

Change Domain name for Production Environment

cd ~/staging/current
bin/magento config:set --lock-env web/unsecure/base_url https://m2-in-a-hurry.com/
bin/magento config:set --lock-env web/secure/base_url https://m2-in-a-hurry.com/
bin/magento cache:clean

Troubleshooting

If you encounter an error message like "Unserialized value" when opening your staging site you can run the below

cd ~/staging/current
php bin/magento setup:config:set --session-save=redis --session-save-redis-host=/var/run/redis-multi-`id -nu`.redis/redis.sock --session-save-redis-max-concurrency=20 --session-save-redis-db=2
php bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=/var/run/redis-multi-`id -nu`.redis/redis.sock --cache-backend-redis-db=0
php bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=/var/run/redis-multi-`id -nu`.redis/redis.sock --page-cache-redis-db=1
bin/magento cache:clean

I believe it happened for me when Nexcess copied over the redis configuration from the live site while spinning up the development instance.

Part 3 - Theme, Category and Product Setup

Part 4 - Installing, Testing and Deploying an Extension

Blog Comments powered by Disqus.
Kristof Ringleff

Kristof Ringleff

Founder and Lead Developer at Fooman


Published

Want to receive our monthly email with the best Magento developer tips, tricks and news? Join 7000+ other Magento developers