Duplicate Shopware 6 in Plesk
This step-by-step guide will show you how to duplicate your Shopware 6 store in Plesk.
Prerequisites
- Managed server
- Shopware 6
- Plesk Control Panel
In summary, duplicating a Shopware 6 store in Plesk offers the possibility to safely test changes, customize the store, perform development processes and improve scalability.
Duplicate Shopware 6
Open the Plesk Control Panel in your web browser. See also: Login to the Plesk Control Panel
Create new website
First create the new website in Plesk into which the store is to be duplicated.
You can create a new website using the Add domain button. To do this, enter the desired domain under which the copied Shopware store should later be accessible.
You can use the working domain of the Shopware server for the copy, for example. This corresponds to the syntax: sXXXX.creoline.cloud. Replace the prefix with your server ID.
Under Webspace, select the webspace of the domain to be copied.
Also specify the system user name that will later become the owner of the Shopware copy on the server.
To additionally secure your website via SSL/TLS, you can set up a free Let's Encrypt certificate for the store copy. You can find step-by-step instructions in the Help Center article Set up Let's Encrypt certificate.
Create database
In Plesk, navigate to Website & Domains and select one of the two domains on which your Shopware 6 copy is or will be installed.
Click on the Databases tab and create a new database that is intended for the duplicated store. See also: Create MySQL database
Copy Shopware 6 store
Under Hosting & DNS โ Hosting settings, remove the document path /public
for the duration of the copying process.
Your Shopware 6 store will be unavailable for a short time due to the change. After the copying process you can insert the /public
again.
Go back to the overview page of the domain and click on the "Copy website" button. The Plesk interface for copying a website opens.
In Plesk you can choose whether you want to copy your Shopware 6 store to a website in Plesk or via FTP connection to another server.
We use the method of copying the website in Plesk and select the name of the website to which Shopware 6 is to be copied. If your website or domain is not displayed, you must first create it in Plesk under Domains. You can also use a subdomain such as dev.meinedomain.de
or dev.sXXXX.creoline.cloud
.
Please note that "Delete all existing files" irrevocably deletes all files in the target directory.
In this case, we would like all files in the target directory to be deleted, as we have created a new domain and therefore no important files exist in the directory. We can confirm the selection by clicking on "OK". The following message appears in Plesk:
Important
Add the document path /public
to both domains under Hosting & DNS โ Hosting settings so that your Shopware 6 store is accessible again.
Copy database
When copying the database, tables are temporarily locked, which can have a minimal impact on the performance of your application for a short time.
To begin with, the database used in the current store should be determined in the Shopware configuration file under /document_root/.env.local
.
The following line indicates which database is being used:
DATABASE_URL=mysql://[DB_USERNAME]:[DB_PASSWORD]@[DB_SERVER]:[DB_PORT]/[DB_DATABASE_NAME]
In our case, the .env.local directive looks like this:
DATABASE_URL=mysql://shopware_6:password@localhost:3306/shopware_6
In Plesk, we navigate to the domain of the current store โ Databases and select "Copy" for the previously determined database.
Once there, we can either create and name a new database or we can use the previously created database.
We want to create a complete copy of the database and confirm this with "OK".
It is recommended that you select the "Create complete copy" option. This avoids complications during the copying process.
We then receive the following message in Plesk and the copy has been successfully completed:
Then adjust the .env.local
file of the store copy to use the database copy.
DATABASE_URL=mysql://[DB_USERNAME]:[DB_PASSWORD]@[DB_SERVER]:[DB_PORT]/[DB_DATABASE_NAME]
In our case, the .env.local directive then looks like this, for example:
DATABASE_URL=mysql://shopware_6_copy:password@localhost:3306/shopware_6_copy
Empty cache
Empty the cache of your copied Shopware 6 store by connecting to the server via SSH.
Navigate to the store root directory of the copied store.
The command could look like this, for example:
/var/www/vhosts/sXXXXX.creoline.cloud/swcopy.sXXXXX.creoline.cloud/
Once there, execute the following CLI command:
php bin/console cache:clear
Shopware CLI commands should always be executed as the system user. Executing as root user can lead to unwanted side effects.
The cache should be emptied, if an error occurs, try to empty the cache manually by navigating to the following path:
/var/www/vhosts/sXXXXX.creoline.cloud/swcopy.sXXXXX.creoline.cloud/var/cache
and execute the following command there:
rm -rf prod_*
Customize sales channel
To customize the sales channel of your Shopware 6 store, log in to your Shopware 6 administration area with the access data that you also used in the previous store.
Once there, navigate to your store and scroll down a little until you can see the Domain tab and adjust both entries so that they correspond to the domain of the copied store.
After customizing the sales channel, click on the Save button in the upper right area to apply the customization.
After customizing the domains, the frontend of the copy of the Shopware 6 instance is accessible under the stored domain in the browser of your choice.
You have now completely duplicated your Shopware 6 store once.