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:
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).
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.
sub Directories
? If he puts his multi-site in Sub Directories eg:sites/site1
andsites/site2
, how do you access it from frontend? I had similar issue once, but this was not achievable without use of Sub Domains..