Environment configuration .env.local

Preface

Shopware overwrites the content of the .env during updates. For this reason, we recommend the use of an .env.local file. This makes it possible to make changes to the environment configuration without Shopware updates undoing them by overwriting.


Requirements

  • Shopware 6 Server
  • SSH access (system user)



SSH connection

You can find detailed instructions on where to find the SSH access data in our Help Center article under System user.


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

ssh benutzer@s12345.creolineserver.com


If you connect as root user, it is mandatory to execute all following commands as system user. Please use the following command:

su <SYSTEM USER>



Creation of the .env.local

To use the .env.local, it must first be created. Once created, it can be used immediately for the configuration of Shopware.


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


There you can list the files and folders with the following command:

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


If there is no .env.local here, you can create it with nano or vim. To do this, execute the following command:

touch .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


Only enter changes in the .env.local that actually deviate from the standard from the .env.


Finally, the file can be closed with CTRL + X followed by Y and then saved with Enter.



Empty Shopware cache

The Shopware cache must then be emptied for the changes to take effect. To do this, use the Shopware CLI and execute the following command:


bin/console cache:clear