Environment Configuration .env.local

Introduction

Shopware overwrites the contents of the .env file during updates. For this reason, we recommend using a .env.local file. This allows you to make changes to the environment configuration without Shopware updates undoing them by overwriting the file.


Prerequisites

  • Shopware 6 Server
  • SSH access (system user)



SSH Connection

For detailed instructions on where to find your SSH login credentials, see our Help Center article on System Users.


You can establish a connection in your terminal using the following command:

ssh benutzer@s12345.creolineserver.com


If you connect as the root user, it is absolutely necessary to execute all subsequent commands as a system user. To do so, please use the following command:

su <SYSTEM_USER>



Creating the .env.local File

To use the .env.local file, it must first be created. Once created, it can be used immediately to configure Shopware.


cd /var/www/vhosts/yourdomain.tld/httpdocs/


There, you can list the files and folders using the following command:

root@s12345:/var/www/vhosts/ihredomain.tld/httpdocs# ls -la
total 488
drwxr-xr-x  9 deployer www-data   4096 Dec 13 13:08 .
drwxr-sr-x  3 deployer www-data   4096 Dec 11 13:34 ..
drwxr-xr-x  2 deployer deployer   4096 Dec 11 1:35 PM bin
-rw-r--r--  1 deployer deployer    334 Dec 11 1:35 PM compose.override.yaml
-rw-r--r--  1 deployer deployer   1635 Dec 11 1:35 PM composer.json
-rw-r--r--  1 deployer deployer 413861 Dec 11 1:35 PM composer.lock
-rw-r--r--  1 deployer deployer   1070 Dec 11 1:35 PM compose.yaml
drwxr-xr-x  4 deployer deployer   4096 Dec 11 1:35 PM config
drwxr-xr-x  5 deployer deployer   4096 Dec 11 1:35 PM custom
-rw-r--r--  1 deployer deployer   1241 Dec 12 1:05 p.m. .env <-- Shopware base configuration
drwxr-xr-x  3 deployer deployer   4096 Dec 11 1:47 PM files
-rw-r--r--  1 deployer deployer    673 Dec 11 1:35 PM .gitignore
-rw-r--r--  1 deployer deployer    369 Dec 11 1:35 PM .htaccess
drwxr-xr-x  7 deployer deployer   4096 Dec 11 4:18 PM public
-rw-r--r--  1 deployer deployer    350  May 3, 2023  README.md
drwxr-xr-x  4 deployer deployer   4096 Dec 11 1:47 PM var
drwxr-xr-x 47 deployer deployer   4096 Dec 11 1:34 PM vendor


If there is no .env.local file here, you can create it using nano or vim. To do so, run the following command:

touch .env.local


Editing .env.local

You can then edit the file using an editor (e.g., nano):

nano .env.local
APP_ENV=prod

APP_URL=https://sXXXXX.creoline.cloud

APP_SECRET=8da9c91497f28736624ad0e1042da579
INSTANCE_ID=cddd58be33805144d39b522a8672b32f

DATABASE_URL=mysql://root:password&@localhost/shopware


In the .env.local file, only enter changes that actually differ from the default settings in the .env file.


Finally, close the file by pressing CTRL + X, followed by Y, and then save it by pressing Enter.



Clear the Shopware Cache

Next, you must clear the Shopware cache for the changes to take effect. To do this, use the Shopware CLI and run the following command:


bin/console cache:clear