Multisite on Drupal

Events happening in the community are now at Drupal community events on www.drupal.org.
liliplanet's picture

Hi Everyone!

Gee, am I struggling to setup a sub-domain that has a separate database but shared users ..

I've done the following:

created a sub-domain at my host that points to mysite.com/sites/subdomain
created a folder sites/subdomain and it has modules, files and themes folder
copied the settings.php file from my default folder (as a test to make it work)

When I go to subdomain.mysite.com all I get is the folders that have been uploaded (modules, files, themes and settings.php)

Multi-site manager is not getting me anywhere :)

Question: Do I have to completely install a new Drupal installation in the subdomain?

What I'm trying to achieve is a sub-domain that users are logged into automatically (from the base site) and has specific modules and theme.

If you have perhaps got this down to an art, would pay for your assistance :)

Look forward to any reply.
Lilian

Comments

not too sure

muximus's picture

not too sure about this but i think you're supposed to name the folder "subdomain.mysite.com" and not "subdomain"

Hi Muximus! thank you for

liliplanet's picture

Hi Muximus! thank you for your reply ..

I've renamed the folder from subdomain to subdomain.mysite.com and still only see the folder directory.

Am I supposed to drop the full Drupal installation into my sub.domain? In other words create a brand new installation, but have the same database?

Maybe that's where I'm going wrong, but was under the impression that a sub-domain could run of the main site's files and sql database.

Look most forward to any reply, and thank you.
Lilian

Hi Lilian, Nope you don't

kirstykf's picture

Hi Lilian,

Nope you don't have to drop a full drupal installation into the subdomain.mysite.com folder, just a modules and a themes folder with the relevant modules and themes if you want to have those specific to your subdomain only.

Basically how shared or not shared the sites will be is dictated by your settings.php file and obviously the modules / themes in your subdomain subdirectory that you have set up. In your settings.php file you need to outline with db tables you will be sharing and which you won't be, by changing:
$db_prefix = 'main_';

TO
$db_prefix = array(
'default' => 'main_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
'sequences' => 'shared_',
);

So say you want your subsite to have all of its own tables and only the users, sessions, role, authmap and sequences table to be shared with your main site then in the above example 'mail_' would be the prefix of all your subsites tables and 'shared_' would be the prefix that your main site tables are prefixed with so that your subsite and your main site would share those tables.

Lastly you would run subdomain.mysite.com/install.php in your browser and it sets up the subdomain site for you basically creating all the database tables that aren't going to be shared.

Hope that makes sense and I've answered your question

Thank you for your reply

liliplanet's picture

Thank you for your reply Kirsty :)

Actually I would like to share all tables, so that should be easy and have uncommented the following in my subdomain settings.php

$db_prefix = array(
'default' => 'main_',
'users' => 'shared_',
'sessions' => 'shared_',
'role' => 'shared_',
'authmap' => 'shared_',
);

Where I'm confused, if I drop in just install.php to my subdomain, it expects the whole drupal installation ..requires install.inc etc ..

How do I run install.php on the subdomain if a full installation is not necessary?

Most appreciate your help Kirsty ..

Lilian

could this help you

TheWagener's picture

Hi Lilian

would this be of any help to you https://drupal.org/project/domain

Hi genuineleather, I've had a

liliplanet's picture

Hi genuineleather,

I've had a look at the domain module, it's pretty big :)

All I really want is a sub-domain with it's own modules and theme.

Is it really that complicated? Would love to hear from you if you have done this successfully ..

Most appreciate all your replies.
Lilian

I haven't done much with multisites

TheWagener's picture

Yes it does look rather big, I haven't used it I just stumbled across it awhile ago, and thought of it when I read your post.

I have used Organic groups but I don't think that will help you.

Hope someone will be able to help you out

The Domain module lets you

burningdog's picture

The Domain module lets you share a user base, and have specific themes for specific sub-domains, but the modules enabled are global. It's very worth looking into, but YOU MUST KNOW WHAT YOU'RE DOING! i.e. spend lots of time reading the documentation, because your specific implementation will most probably different than the normal use case. The Domain module README is very comprehensive - after reading it, you'll know whether it's fit for your purposes or not.

Hi Lilian

jaqkar's picture

I have done this, multi site that can use either sub domains or a full domain with its own themes and modules. I have set it up to also work in folders on the file structure. So when i want mydomain.com/projects that will read from a folder thats next to my drupal.

It was a combination of these that ended up working for me:

http://blog.tremend.ro/2009/10/20/how-to-move-drupal-to-a-subdirectory-a...
http://acquia.com/blog/migrating-drupal-way-part-iii-managing-multiple-s...
http://acquia.com/documentation/tutorial/symlinks
http://drupal.org/getting-started/6/install/multi-site
http://chirale.wordpress.com/2008/07/04/make-drupal-working-in-a-subdire...

Pointing

kirstykf's picture

Hi Lillian,

Just had another read of your top comment and I see that you have:
"created a sub-domain at my host that points to mysite.com/sites/subdomain"

Drupal actually handles the management of the subdomains for you so you don't have to point your subdomain to "mysite.com/sites/subdomain" you should just point to straight to mysite.com. Drupal then looks for the site in your sites folder and reads the settings.php from there. That would explain why you are getting the error that it can't find the install.php file.

Most appreciate everyone's

liliplanet's picture

Most appreciate everyone's replies :)

@ kirstykf : I've removed the subdomain on my host and now we do have some advance

Maybe there is something wrong in settings.php? I have:

  • To provide prefixes for specific tables, set $db_prefix as an array.
  • The array's keys are the table names and the values are the prefixes.
  • The 'default' element holds the prefix for any tables not specified
  • elsewhere in the array. Example:
  • $db_prefix = array(
    'default' => 'main_',
    'users' => 'shared_',
    'sessions' => 'shared_',
    'role' => 'shared_',
    'authmap' => 'shared_',
    );

@ jaqkar thank you for the links, I've actually gone through them for several days now, and still no cigar :)

Look most forward to any reply, and again thank you so much for your kind assistance.
Lilian

OK, I think I'm going to be

liliplanet's picture

OK, I think I'm going to be hand-held through this process and prepared to pay for your time :) Presuming it won't take long, just to get this working.

Hi Lilian, It really looks

kirstykf's picture

Hi Lilian,

It really looks like the subdomain pointing is not being pointed to the right place, are you quite sure that the subdomain is being pointed to the root of your directory - does it perhaps need to be pointed to a public_html subfolder? Perhaps it is worth scrapping the subdomain and setting it up again to be sure.

Wow, so close yet so far on

liliplanet's picture

Wow, so close yet so far on creating a sub-domain

The reason I previously did not get install.php was by not having created a symlink, so that's all good now.

I created a separate database for my new sub.domain and it installed successfully.

Yet, when I visit the site it still gives me the Apache config. I wonder if I need to park the sub-domain on top of my main domain? Maybe point the IP to my sub.domain?

Any help would be so much appreciated :)

Look forward to any reply.
Lilian

Hi Kirsty! Thank you for your

liliplanet's picture

Hi Kirsty!

Thank you for your reply. Kirsty, the sub-domain setup on my host via Cpanel points to mymainsite.com/public_html .. should it rather be pointed to subdomain.mysite.com/public_html?

I've even tried removing the sub-domain on the host, but then get 'not found'.

As mentioned, installation went well, and even received the welcome message, but when I click on the link in the email to confirm, says index.php not found.

So appreciate your help :)
Lilian

Hi Lilian, It is purely a

kirstykf's picture

Hi Lilian,

It is purely a browser cache issue, if I go to http://social.filmcontact.com in a different browser to the one I opened it in yesterday it opens the Drupal welcome page with no issues. If I try open in Firefox like I did yesterday I get that redirect page. If you go direct to http://social.filmcontact.com/index.php in your default browser you should be able to open the site fine.

Hope that helps :)

Kirsty yes! It certainly was

liliplanet's picture

Kirsty yes! It certainly was a cache issue ... little dance here :)

Now what I've noticed is:

  1. that the users are not shared, so basically I'm the only one on the sub-domain
  2. all the modules from the main site are there, but not the ones in my sub-domain modules folder

What I want is the users and roles to be shared/(shown) on the new sub-domain and it have it's own modules, is that possible?

What I've done to set this up so far:

Created a separate sql database for social.filmcontact.com as example:

film_social = socialfilmcontact.com
film_main = filmcontact.com

On installation had:

shared elements un-commented

Mmm, I will start again, but this is a major jump forward, thank you so so much!
Lilian

Lillian I think you are maybe

Max_Headroom's picture

Lillian
I think you are maybe just one step away:
Your link still goes to the subdomain, instead of the multi-site files.
Delete the folder that the subdomain created with FTP. Do not delete the subdomain in your control panel itself.
Symlink will point to the correct folder.
We discussed it here some time ago for D5:
http://groups.drupal.org/node/15794#comment-55502
And I assume you are following these steps for Cpanel:
http://drupal.org/node/125539

Quentin

Symlink

Max_Headroom's picture

Oh, and your symlink should be:

<?php
symlink
( '/home/username/public_html/', 'social' );
?>

or
<?php
symlink
( '.', 'social' );
?>

Remeber to unlink you previous attempts first

Quentin

Oh my goodness, this is day 4

liliplanet's picture

Oh my goodness, this is day 4 now and still not able to install a multi-site with shared users and roles ..

This is what I've done step-by-step:

Created a sub-domain on my host to point to filmcontact.com/public_html
removed the folder that the host created

in sites/

created network.filmcontact.com
added modules and themes folders
copied settings.php from default

<?php
$db_url
= 'mysqli://myusername:mysecretpassword@localhost/my_database';
$db_prefix = array(
'default'   => 'network_',
'users'     => 'main_',
'sessions'  => 'main_',
'role'      => 'main_',
'authmap'   => 'main_',
);
?>

no base url or cookies

created a symlink

when I go to install.php get many errors as follows:

Warning: Table 'main_sessions' already exists query:
Warning: Table 'main_role' already exists query: etc etc

Fatal error: Call to undefined function user_access() in /home/public_html/includes/theme.inc on line 1776

I'm really lost now, does anyone perhaps see what I've done wrong, or maybe it's the set up on my server? Something is up :)

Would most appreciate any help (paid) to get me up and running please.

Lilian

Hey, Great, you so close

kirstykf's picture

Hey,

Great, you so close now!! :)

So your db array in settings.php looks like this:

$db_prefix = array(
'default' => 'film_social_',
'users' => 'film_main_',
'users_roles' => 'film_main_',
);

If the above WASN'T in your settings.php when you ran the install then you will have to delete the db tables and start again.
Also, this does need to be in the same database as your original site so that when the subdomain reads / writes to the database it has access to both sets of tables. So the single database will have both the film_main tables and the film_social tables. The installation on your subdomain is only going to set up the film_social tables so the tables for your main site need to already have the film_mail prefix.

Then the modules specific to your subdomain are situated in: /sites/social.filmcontact.com/modules/ correct? Drupal really should pick them up from there when you log into social.filmcontact.com and go to the modules section?

what do you mean by "On installation had: shared elements un-commented"

Hope this helps, you multisite is so close now.

lappies's picture

Liliplanet
How far did you get? Seems the subdomain http://network.filmcontact.com is not working yet.

I did my install sequence of multisite (same codebase) [or multiple site (Different codebase in sperate subdirs) differently.]

You are so close now.
It seems you did set up (park) correctly the subdomain in cpanel and made the subdir in sites folder. However I used only the default table prefix for the new subdir's installation (Later after installing and configuring it, I put/switch to the shared tables in the settings.php.)
So I would install with
$db_prefix = array(
'default' => 'film_social_',
);
in settings and use the same database as the main site. (So two separate sets of drupal files is in the same database but with different table prefixes.)
When I am more or less finished with the settings in the sub-site and like what I see, I would then just change the shared table settings in the settings.php file to
$db_prefix = array(
'default' => 'network_',
'users' => 'main_',
'sessions' => 'main_',
'role' => 'main_',
'authmap' => 'main_',
);

Login in on both sites is also so simple by using the same .filmcontact.com as cooky-domain in settings.php. [.] dot is NB in both settings files and then it is just bingo (Drupal use the same for their own sites.
Hope this helps

Hi lappies, Sorry, I seem to

liliplanet's picture

Hi lappies,

Sorry, I seem to have missed your post which was added a while ago :)

Actually I decided not to go with a sub-domain because it is so complicated to share tables from the realname.module

When you share the users table, you just get username and I wanted the full name to appear on the sub-domain.

Anyhow, it's all good ..

Wishing you a great week.
Lilian

South Africa

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: