1

We need to develop multiple websites on Drupal with the following structure. (We are migrating from DotNetNuke.)

  • www.mainsite.org
  • www.mainsite.org/subsite1
  • www.mainsite.org/subsite2
  • possibly, www.mainsite.org/subsite1/subsubsite1

 

Unfortunately, using sub-domains is not an option. There should be superusers who can administer all the sites and subsites, and site-specific administrators for each sub site.
We want to use the same Drupal code base and database.

Is this possible with Drupal core, or is there a Drupal module to achieve this?

4
  • @GisleHannemyr, he says subdomains is not an option.
    – user12947
    Nov 4, 2013 at 11:38
  • @JhilkeDai Sub directories
    – Clive
    Nov 4, 2013 at 12:03
  • Alrite, but with Core Drupal how do you call sites under sub Directories? If he puts his multi-site in Sub Directories eg: sites/site1 and sites/site2, how do you access it from frontend? I had similar issue once, but this was not achievable without use of Sub Domains..
    – user12947
    Nov 4, 2013 at 12:10
  • Troubleshooting Drupal multi site may be painfull. If you have a terminal to the server, you may have try strace , which gives you you a better idea of how Drupal reads your filesystem see more here drupal.stackexchange.com/a/123231/13760
    – Augusto
    Jul 11, 2014 at 13:17

2 Answers 2

4

All your points can be fulfilled with just the core (i.e. no need to install a module for this).

Setting up a multisite with subdirectores (even multiple levels of subdirectories) is standard fare in Drupal. How you set this up is explained in the standard documentation. You may also want to see my blog about setting up a multi-site. The article covers all three options:

  • DNS alias: example.org + example.com.
  • Sub-domain: example.org + sandbox.example.org.
  • Sub-directory: example.org + example.org/sandbox.

(It also discusses setting up a shared database, but only the simplest use case, where each site has its own content, users and configuration. I've yet to write about the use case where not only the datebase, but some of the tables too are shared.)

One mis-informed individual seems to think that you can't do this with sub-directories. So just for the record, here is an example of a muli-site set up to use sub-directories:

To address your other concerns:

There should be superusers who can administer all the sites and subsites, and site-specific administrators for each sub site.

The simplest way to do this is to have separate {users} tables for each site that is part of the multi-site. You then just use the standard Drupal role based access control systems to set up the superusers and and site-specific administrators. But you may also share the {users} table between all sites (as explained below) to have a single front-end for managing the users to all the sites.

We want to use the same Drupal code base and database.

The whole idea behind multi-sites is that the Drupal code base is shared, so that happens by default.

As for sharing a database, there are two options, and your question does not specify which you want:

  1. Shared database, but each site has its own content, users and configuration. This is simple to set up. Just create the database, and during installtion, pick a different table prefix (site1_, site2_, etc.) when you set up the database for each site (this is under "Advanced" on the db configuration panel).

  2. Shared database, where some tables (e.g. {users}) are shared between sites. To have this, you need to set up your database to use multiple prefixes. The accepted answer to this question tells you the basics of how to use prefixes to share some tables between multi-site instances (in the example shown, the tables {users}, {sessions}, {role}, and {authmap} are shared). There is also a project Domain Access that helps you with sharing stuff between sites, but I am not familiar with it. If you try to use it, and run into problems, ask a new question about it.

Final note: If you want to share a lot of tables between sites, using the Organic Groups project to manage permissions, users and contents on a single site may be a better solution than deploying a multi-site.

2
  • you might have answered the question as it only asks if it is possible. But I'm really interested to know how you accomplished it with Same Core base and Same Database. Have you written any blog or something like that about the steps? I am really curious to learn about it. Thanks
    – user12947
    Nov 4, 2013 at 13:06
  • @GisleHannemyr Thanks for your answer. We want a shared database with as many tables as possible shared. We are trying to avoid duplicate tables. Nov 4, 2013 at 14:02
0

The Drupal multisite feature allows you to use multiple databases using the same database. If you are trying to share as much data as possible, though, then it would be a mistake to use multiple database. The Drupal feature that allows you to share tables with prefixes should be avoided; some tables, such as the variables table, are hard to share. Going down this road requires a lot of knowledge about the internals of Drupal and all of your contrib modules, and will introduce maintenance problems.

A better solution for sharing data is to just have a single Drupal site. Use organic groups to give different users different permissions in different parts of you site. Use the context module to define specific paths in your site (e.g. subsite1, subsite2, subsubsite3) that should look or act differently. You can then user Organic Groups Theme to set a completely different appearance for your site based on the group that is being viewed.

I have used this technique quite successfully with the Domain Access module; however, in your case, you do not have multiple subdomains, so you do not need this module. Just set up your organic group paths to match your subsites, and og_theme will provide the illusion that these areas are completely different sites.

Your Answer

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

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