How can we help you today?

How to Use a Basic Staging Environment With Shopware 6

Created by: Rens Zuurbier

Modified on: Fri, 29 May, 2020 at 9:23 AM


A staging environment is very useful, for things such as: 

  • Let a customer (shop-owner) try out a proposed change 
  • To quickly make a copy of a production shop to analyse a bug that didn't show up during development 
  • Automated testing by external tools 

This article explains how you can set up a staging environment on Hypernode for a Shopware shop. 

Keep in mind: 

  • Your staging environment shares resources (disk, CPU, mem) with your production site. If you want to do things such as automated load tests, it is recommended to order a development plan instead, so your production site will not be affected. 
  • We don't recommend creating hard links from your production media folder to your staging media folder as our back up mechanism does not cope well with hard links.


How To Make a Copy of a Live Site

Set up your staging environment by following the steps. It is strongly recommended to use separate databases for your staging environment, so using the staging environment will not interfere with the production data.

Step One: Copy Your Shopware Files to the Staging Directory

rsync -va --delete --delete-excluded \
--exclude /var/cache/ \
/data/web/shopware/ /data/web/shopware_staging/

Step Two: Create a Staging Database

mysql -e create database if not exists staging

Step three: Connect Your File System to the Database

editor /data/web/shopware_staging/.env

Make sure to change the DATABASE_URL value to your staging database. Change the databasename after the "/" into your staging databasename: "staging"

Step Four: Dump the Production Database and Import Into the Staging Database

mysqldump $databasename | mysql staging

Step Five: Change the SHOP_URL in /data/web/staging/.env

editor /data/web/staging/.env

Make sure you edit the value of APP_URL to your Hypernode-URL: APP_URL="http://APPNAME.hypernode.io:8888/"

Step Six: Change the URL in the sales_channel_domain Table for Your Staging Database

Now to use the staging environment, we need to change the base URLs to use the ports for the staging environment. This way your site is accessible through the same URLs as the production shop but will be using different ports. We change the HTTP port to 8888 and the HTTPS port to 8443. Please note to check which ID is relevant for your URL with the select * from sales_channel_domain; query.

mysql
> use staging
> select * from sales_channel_domain;
> update s_core_shops set host = ‘APPNAME.hypernode.io:8888' where id = 1;

Step Seven: Set the Symlink

The final step is to create the symlink.

rm -rf /data/web/staging
ln -s /data/web/shopware_staging/public/ /data/web/staging
R
Rens is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.