1

Is it possible with Drupal to have two sites, with 2 separate databases, sharing the same PHP code?

For the future need of porting one database to another server, I don't want to use "Multi Site Installation".

1 Answer 1

3

Yes, you can run several independent Drupal sites off the same codebase. Some instructions are here: https://www.drupal.org/documentation/install/multi-site

Basically, each has its own database and its own sites/yoursite.org folder where the settings files and site-specific files go. All use the sites/all folder. When you visit via http://yoursite.org, Drupal checks the sites/yoursite.org folder for a settings.php file, and if there is no sites/yoursite.org folter, it uses sites/default. (There's a more nuanced pecking order of folders, but this is the gist.)

For CiviCRM, it works the same: you put civicrm.settings.php in sites/yoursite.org, and the module lives in sites/all/modules. Your database is independent of the other sites; the only thing shared is the module code.

However, there is a reason why many people don't set up their sites this way: there's not much benefit to having a single copy of the modules (the files aren't that big), but you can do things on one site that inadvertently cause problems on one of the others. As an example, if you upgrade one site's CiviCRM, you're replacing the files used by all of your sites, requiring you to run the upgrade script on all of them.

4
  • Thank's Andrew, and what about extensions and "customized" templates? I mean, having a single code, it's possible to have a specific template for different sites?
    – marcello
    Commented Apr 26, 2016 at 12:09
  • Yes. Your extensions and template overrides will be in sites/yoursite.org, so they'll be site-specific.
    – Andie Hunt
    Commented Apr 26, 2016 at 13:29
  • Tanks I have understand the logic, But in my developement server I don't use domains. So my base URL is 127.0.0.1/drupal and my base drupal folder C:\localhost\drupal\sites. Where I have to put my new default.settings.php?
    – marcello
    Commented Jun 9, 2016 at 6:20
  • You'll need some way for the system to know which site you want. The most straightforward way is to edit your hosts file (often /etc/hosts, but something else for you on Windows) to point fake domains to 127.0.0.1. If you have one entry reading 127.0.0.1 onesite.dev and the other reading 127.0.0.1 othersite.dev, you'll put settings files at sites/onesite.dev/settings.php and sites/othersite.dev/settings.php. You may need to configure Apache to serve the folder from those virtual domains.
    – Andie Hunt
    Commented Jun 9, 2016 at 17:03

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.