1

I am new to Magento and I have noticed that everytime I run:

bin/magento setup:install --base-url=http://localhost:8090 
--backend-frontname=admin 
--db-host=magento_mysql
--db-name=webshop 
--db-user=admin
--db-password=test1234
--admin-firstname=admin 
--admin-lastname=admin 
[email protected] 
--admin-user=admin 
--admin-password=test123 
--language=nl_NL 
--currency=EUR 
--timezone=Europe/Amsterdam 
--use-rewrites=1 
--elasticsearch-host=elasticsearch 
--elasticsearch-port=9200

The config.php and env.php file are being regenerated.

What I would like to accomplish is to have a default template with my custom configurations in those files and load in the database information and other sensisitive data from a .env file. Using getenv("DB_PASS") to retrieve the environment variables inside env.php.

The idea is that Magento will run inside Docker and when I deploy it to a server I don't want the install script to overwrite my local config files.

So is there a way to pre-configure Magento with custom env.php and config.php and make it use those files when setting everything up?

4
  • 1
    Why run bin/magento setup:install more than once? You can actually install your own config.php and env.php file prior to running setup:install. Keep in mind you probably shouldn't be running setup:install more than once Apr 11, 2022 at 19:25
  • @ShawnAbramson I am looking for a way to setup a deployment pipeline for Magento using Docker. Without having to push framework specific code to the server. Apr 12, 2022 at 7:08
  • 1
    You can always re-install the same config.php and env.php file and then run either setup:install or setup:upgrade. If either file exists prior to running the install command, it will not be overwritten Apr 12, 2022 at 12:54
  • I wasn't aware of setup:upgrade, that looks promising. Will use that. I probably will not have to run it a lot. I realize that composer install generates a lot of files for allready. I can just push my env.php and config.php and then restore an initial database dump that can be shared among the team to make magento work out of the box without running setup:install Apr 15, 2022 at 10:26

1 Answer 1

1

I think magento install will always generate these files. That being said, you can replace them after your installation and they will change. For exemple for people working on remote database it's quite common to swich their env to go and check the database of a coworker.

The config.php can be locked and defined by the data stored. So most of the time you can just put that fine on git to use it.

1
  • Replacing the env.php file after install might be a good option. Will look into this. Apr 12, 2022 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.