Modifying local DDEV Drupal settings.php for live server?

822 views Asked by At

I'm using DDEV for local Drupal 9 development and it's great. Now, for the first time ever, I'm trying to take a local site and put it on my hosted server, which is an absolutely normal Linux and cPanel based hosting service. I "get" the basic procedure, but I can't get the "last few yards" down. I "get" this:

  • export the local DDEV database with ddev export-db
  • import it through cPanel on the remote server, say with phpAdmin
  • export all the files, say as a tar.gz
  • upload to cPanel, and put them all in the root directory

But beyond this, I'm rather stuck, and I know there is more to do. In particular, I know I have to modify settings.php. But I know that in the local environment, DDEV manages it and makes its own file, etc. but I'm just not clear on exactly what I have to do here without breaking the whole thing.

And of course I don't know whether are additional things I have to also do to tweak the site to get up and running.

Obviously many have done this, so could somebody point me to maybe some write-up that somebody might have done?

Thanks!

1

There are 1 answers

1
rfay On BEST ANSWER

Great question!

DDEV-Local doesn't actually want to generate a settings.php for you, it would rather just add the include of settings.ddev.php to your existing settings.php.

The easiest thing to do is to copy default.settings.php to settings.php (just overwrite the settings.php that ddev created) and then do a ddev start. ddev will then add the include of settings.ddev.php and everything should go smoothly.

From there:

  • Uncomment the include of settings.local.php in the settings.php file.
  • Make any other "all the time" changes you want to make in the settings.php (But do not include database details.)
  • Check the settings.php into git, making sure it doesn't have any private or server-specific details. (Not everybody does this, but it's my preference.)
  • On any deployed server, put the database details and any other server-specific items into settings.local.php

Note: DDEV-Local v1.16+ (currently in alpha) does use default.settings.php as the base for the generated settings.php.