I'm planning to install Drupal 6.4 for multi-sites at my shared hosting provider. I'm not sure about it and never done it before (I'm even kind of new to Drupal itself). (please excuse me for my english, I'm no native speaker, as you might guess ;-))

If I understand it correctly (please correct me, if I'm wrong):

  • I can install Drupal in http://example.org/drupal/, and there I put every "website" I want to create into the "sites"-folder. And it doesn't matter, how I name the subfolders. Both correct?
  • Then I have to create a redirect at my shared hosting account from http://example.org/drupal/sites/example.com to http://example.com. Correct?
  • Modules:
    Should I install "popular" modules (like CCK, View, pathauto, ...) in /sites/all/ (that means, every website can use them, correct?) or should I install for each site an own module in its subfolder? I'd guess, I should use the /all/ folder, but I'm wondering: wouldn't it be "safer" to install an own "CCK" for every website? Because, I'd only have to upgrade CCK for that sites, where I need new functionality and so there is no risk, that it corrupts a website. Or is module upgrading usually no problem in Drupal?

    Databases:
    Should I create all the databases (I want 1 database for 1 website) under example.org/ (my multi-site installation), or under each used websites domain (like example.com, site2.example.com, etc.)?

    Login:
    Do the admins of all websites log in at example.org/drupal/ or at each website of that multi-site installation?

    Redirect:
    As stated above, I think I have to redirect from example.org/drupal/sites/... to the domains I want to use. Can anybody "see", that the Drupal version is not installed at the account of the used domain, but at a different domain? Uhm, hard for me to express ... I mean: is there any way to analyze, that e.g. the images etc. don't really come from site2.example.com but from example.org/drupal/? (maye with server ip logging or something of such things I don't understand a word ;-))

    sites/default:
    Is there anything useful I can do with the installation itself? I don't want to publish a websites there (if so I'd have to create it in the default folder, right?). Is it maybe possible to see the logs/statistic of all websites in this account? So that I only have to login into 1 account, if I want to check what's happening at all sites?

    "Export" Drupal installation for one site:
    Is it possible to "exclude" one website of the multi-site installation with it's own installation? Let's say I want to transfer this websites domain with it's content to a friend. Of course I don't want to host his installation at my account.

    Drupal upgrade
    Is upgrading a multi-site installation to the next "big" version (Drupal 7.x) a "no go", or is it no problem?

    Comments

    matkeane’s picture

    Wow, there are a lot of questions there! I'm not sure I have the answers to all of them, but here goes...

    I can install Drupal in http://example.org/drupal/, and there I put every "website" I want to create into the "sites"-folder. And it doesn't matter, how I name the subfolders. Both correct?

    Sort of... When Drupal receives a request for a site, it checks the domain and then looks in the 'sites' folder to see if there is a folder with the corresponding name (including whether the www prefix matches or not). So your subfolders should be called 'www.example2.com' or 'example3.net' and so on.

    Drupal itself just has to be installed some place on your shared hosting account where you can find it. More on that in a second...

    Then I have to create a redirect at my shared hosting account from http://example.org/drupal/sites/example.com to http://example.com. Correct?

    If you mean a file redirect, then no, not really - You would normally setup a domain redirection for your other domains to point at the Drupal installation, and Drupal will find the right site folder to use.

    To try and make this a bit clearer, this is how things are set up on my shared server

    /drupal <- Drupal install
    /drupal/sites/all/modules/ <- contrib modules
    /drupal/sites/www.example.com
    /drupal/sites/www.example2.com
    /www/ <- the normal public web folder

    Now, any domains I want to use with Drupal are configured to point to the /drupal folder and, as long as there is a corresponding subfolder in 'sites', Drupal will use that.

    Hope that makes sense!

    Should I install "popular" modules (like CCK, View, pathauto, ...) in /sites/all/

    Short answer - yes. If you have a copy for each site, you're going to create a lot of work for yourself when it's time to update a module. You're right that any problems with a module will affect all sites, but that's why you have a development copy of everything on another machine to test before deployment on the server, right?

    Should I create all the databases (I want 1 database for 1 website) under example.org/ (my multi-site installation), or under each used websites domain (like example.com, site2.example.com, etc.)?

    That depends entirely on the content of your sites - if you want to share content across the sites, you can use the same database, but generally, I think life is simpler and safer with a database for each site.

    Do the admins of all websites log in at example.org/drupal/ or at each website of that multi-site installation?

    Depends on how you do things with your databases - by default, each site will have a separate list of users, so you'll have to log-in to each site to administer it. You can share some tables in a database though, and use the same 'users' for all your sites.

    As stated above, I think I have to redirect from example.org/drupal/sites/... to the domains I want to use. Can anybody "see", that the Drupal version is not installed at the account of the used domain, but at a different domain?

    Visitors to www.example2.com will not be aware that they arrive on the same server as www.example.com unless they start comparing IP addresses.

    Is it possible to "exclude" one website of the multi-site installation with it's own installation? Let's say I want to transfer this websites domain with it's content to a friend. Of course I don't want to host his installation at my account.

    In that case, it sounds like you'd need a second Drupal install with a separate database. However, depending on the access you want to grant to your friend - i.e. if they are only using the Drupal admin pages, and not uploading modules - I'd say that you can run sites for different people on the same Drupal installation, as long as you carefully separate files and database content.

    Is upgrading a multi-site installation to the next "big" version (Drupal 7.x) a "no go", or is it no problem?

    Dunno, I'll let you know when 7 is released! It's a good question though, and one I'm facing with my shared 5.x install. I think the safest way will be to export the content, taxonomy and users, and the reimport them into the new site.

    no2e’s picture

    Hope that makes sense!

    It does, thanks.

    /drupal <- Drupal install
    [...]
    /www/ <- the normal public web folder

    Does it mean, that you installed Drupal outside of the public folder, or am I getting it wrong? That's something I can't do with my shared hosting provider, I think. Would it be a security risk?

    but that's why you have a development copy of everything on another machine to test before deployment on the server, right?

    Uhrm, yes ... no. I should, but I'm often too lazy and change my local system often, so that I don't have a local LAMP installed. How do you do it? "Clone" your installation to your local machine? Or do you clone it online?

    That depends entirely on the content of your sites - if you want to share content across the sites, you can use the same database, but generally, I think life is simpler and safer with a database for each site.

    Yes, I want an own database for each website. But I don't know, if I have to create all databases at example.org (the domain of the multi site installation) or each database under each websites domain account (site2.example.com, etc.).

    In that case, it sounds like you'd need a second Drupal install with a separate database.

    Yes, that's what I want to do. But is it possible, when I created the website as part of a multi-site installation? So, can I install a fresh Drupal at the selled domain and import all files/settings and the database without problems? At the multi-site installation the /sites/example.com folder was used, but now I'd have to use /sites/default - so, is this possible?

    Dunno, I'll let you know when 7 is released!

    Hehe, okay. Is there any release estimate? Can't find much info about it. Is it likely to be released this year?

    ----
    current requests: multi-site | OpenID | (template) editor inside drupal

    matkeane’s picture

    Does it mean, that you installed Drupal outside of the public folder, or am I getting it wrong? That's something I can't do with my shared hosting provider, I think. Would it be a security risk?

    My setup is based on this article on creating a more secure Drupal multi-site install: http://justinhileman.info/blog/2007/06/a-more-secure-drupal-multisite-in...

    The advantage is that each site appears entirely independently on the server, and has its own htaccess and files folder (unless you change the file system config, Drupal will dump all files from all your sites into /files/). They can even be set up with independant FTP access. The disadvantage is getting your head around all those symbolic links on the server! Unless you really need to go that route, and have a dedicated server with shell access, it's probably not worth the hassle. I'd get to grips with a normal Drupal multi-site install first.

    I don't have a local LAMP installed. How do you do it? "Clone" your installation to your local machine? Or do you clone it online?

    Take a look at WAMP, or MAMP if you're on a Mac, as it provides a very simple LAMP stack install. Then you just need to export/import your database between your remote and local servers and you have a clone of your site.

    Likewise, if you decide to split off one of the sites and move it to a separate Drupal install or server, you just need to copy across the files in the sites/www.example.com/ folder - to make sure you have any themes, modules and files - and export your database.

    Yes, I want an own database for each website. But I don't know, if I have to create all databases at example.org (the domain of the multi site installation) or each database under each websites domain account (site2.example.com, etc.).

    Often, the databases will be hosted on a completely different server to your site, so the databases might be accessed by IP address, or something like database.yourhost.com - depends entirely on your hosting setup. To a certain extent it doesn't matter where they are, as you just change each sites' settings.php file to suit.

    Hehe, okay. Is there any release estimate [for D7]?

    I'll worry about moving to 6 first! I think Dries said something in his Keynote about looking towards an end-of-year release.

    no2e’s picture

    .htaccess in Drupals main folder:

    # To redirect all users to access the site WITHOUT the 'www.' prefix,
    # (http://www.example.com/... will be redirected to http://example.com/...)
    # uncomment and adapt the following:
    # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
    # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

    I want to use this redirect for all my websites.
    I installed Drupal into http://cms.example.com/drupal/. I placed a .htacces into the root (cms.example.com/) with:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.cms\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://cms.example.com/$1 [R=301,L]
    

    This works. When I try to open http://www.cms.example.com/, it gets redirected to http://cms.example.com/. But when I call http://www.cms.example.com/drupal/, the www. stays where it is (no redirect). I presumed that Drupal "overrites" this, so I uncommented the 2 lines in Drupals own .htaccess and changed them as follows:

    RewriteCond %{HTTP_HOST} ^www\.cms\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://cms.example.com/$1 [L,R=301]
    

    But now I get redirectet to http://cms.example.com/ when I try to call http://www.cms.example.com/drupal/. That means: I can't call Drupal, when I enter the URL with www.

    What's wrong? Should I enter the folder /drupal/ in Drupals .htaccess (is it allowed at all? ; if yes, how exactly?)?

    And further question:
    does it work for the multi-site websites automatically? Or where do I have to put their own .htaccess?

    ----
    current: multi-site | OpenID | online editor | Automatic filenames

    no2e’s picture

    Now I uncommented RewriteBase /drupal in Drupal's .htaccess.
    And I set the base_dir in settings.php to $base_url = 'http://cms.example.com/drupal';

    ... it's still not working :(

    ----
    current: multi-site | OpenID | online editor | Automatic filenames

    matkeane’s picture

    Hi,

    Unless you want to host some static files on the site alongside your Drupal sites, you might find it easier to move the Drupal files to the root - e.g.

    www.example.com/index.php
    www.example.com/includes/
    www.example.com/misc/
    www.example.com/modules/
    www.example.com/sites/all/modules/
    www.example.com/sites/cms.example.com/

    That way, you can restore the default Drupal htaccess file, and just worry about the www or not...

    I wonder whether it is in someway related to the way the host is configured, but I have a fairly complex multi-site install running happily, but I fell at the first hurdle when I tried to install Drupal in a subdirectory!

    no2e’s picture

    you might find it easier to move the Drupal files to the root

    I need to have Drupal installed in a subfolder.

    I can't be the only one with this problem, can I? It's still a "normal" installation (got no multi-site yet).

    ----
    current: multi-site | OpenID | online editor | Automatic filenames

    matkeane’s picture

    I need to have Drupal installed in a subfolder.

    Fair enough - should work, but you need to carefully check your .htaccess. If you've uncommented the Rewrite base line in Drupal's htaccess and added it in settings.php, you should be sorted. What happens if you remove the root level htaccess?

    bobthecow’s picture

    That redirect is executed relative to the current directory... Because the .htaccess file is in the /drupal/ directory it will grab the 'path' chunk of the url (the part inside parenthesis) relative to the current directory, and it will not get the /drupal/ part. Try this instead:

    RewriteCond %{HTTP_HOST} ^www\.cms\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://cms.example.com/drupal/$1 [L,R=301]

    I personally like to write the first line like this, as it specifies "allowed" values rather than enumerating badness:

    RewriteCond %{HTTP_HOST} !^cms\.example\.com$ [NC]
    

    But that's not necessary, it's just prob'ly a better practice.

    bobthecow’s picture

    If you're interested in knowing why the RewriteBase rule didn't work in your case...

    RewriteBase sets up the base part of a rewritten url. For example, it says that if our drupal install is locate at example.com/drupal, we would rewrite everything relative to that /drupal directory. So a rule like...

    RewriteBase /drupal
    RewriteRule ^foo$ bar
    

    ... adds an implied /drupal folder in front of bar, rewriting example.com/drupal/foo to example.com/drupal/bar. This works for in-site redirects. External redirects, such as the canonical domain redirect, can't use the RewriteBase, so you specifically have to add that to the rewrite rule if you're running drupal in anything but the top folder of the domain.

    Thus RewriteRule ^foo$ http://example.org/bar wouldn't make it to the drupal install, but RewriteRule ^foo$ http://example.org/drupal/bar would work just fine.

    You still need the RewriteBase directive for the important redirect (the one that redirects clean urls to index.php?q=...), but it doesn't actually solve the canonical domain redirect.

    I guess that should prob'ly be mentioned in the .htaccess file.

    no2e’s picture

    RewriteCond %{HTTP_HOST} ^www\.cms\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://cms.example.com/drupal/$1 [L,R=301]
    

    This worked! Thank you, bobthecow :)

    Got another problem now:
    http://groups.drupal.org/node/17217

    no2e’s picture

    Hmmm ... with this .htaccess settings the Clean URLs of my additional sites are not working anymore. So I restarted with the default .htaccess again. Clean URLs are now working for all my multisites, but I need that www to non-www redirect, again. :/ Any ideas?

    no2e’s picture

    Could someone help me?

    I have a running multisite setup with Drupals default .htaccess. Everything's fine, except:
    --> I want all multisites to redirect from www to non-www.

    What do I have to edit for which site in which way? And where? Everything in Drupals .htaccess in ROOT?
    (there are multisites with SUBDOMAIN.example.org and with example.org/DIRECTORY and with combinations of both)

    bobthecow’s picture

    That non-www redirect doesn't work on a multisite setup, since it's necessarily specific to an individual site... Your best bet will be to do a multisite setup like this, since that allows each site to have its own .htaccess file, while still sharing a single codebase.

    no2e’s picture

    There is a solution - www. to non-www. redirection works with multisites (and only one .htaccess file):
    http://groups.drupal.org/node/17750#comment-61199

    Anyway, I'd love to tweak the multisite setup the way you linked it, but unfortunately I don't have shell access (which is not possible at the most of the shared hosters).

    alakesh’s picture

    .