Greetings, all. I am BRAND NEW to Drupal, as I was informed last week that a co-worker is leaving and I will be responsible for the Drupal-based site development and maintenance when he leaves. So I have been working on learning as much as I can, as quickly as I can. I thought a good place to start would be with the "Drupal Cookbook (for New Drupallers)" available here on the Drupal site. I was going through the steps there, and got to "C. Creating Multiple Sites On Your Local Computer" and got stuck. I had 2 different issues. The first, I was able to partially work around but they are still ongoing. Here they are:

1.) When I followed the directions step-by-step on 2 different machines, I got the same results. When I tried to access the new site (http://working_drupal), I got an error message that stated that user "admin@localhost" had no access to the database. I looked in settings.php on my working_drupal site, and sure enough it is looking for a user called "drupal_user". When I looked at the database priveleges for working_drupal, it appears as though "drupal_user" was not copied over from the original drupal database.

2.) As a workaround for (1) above, I got the drupal username and password from settings.php in working_drupal, and ran the SQL query to grant permissions to that user on the working_drupal database:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES,
LOCK TABLES on working_drupal.* TO 'drupal_user'@'localhost' IDENTIFIED BY 'drupal_db_wdp';
FLUSH PRIVILEGES;

When I ran this, and launched my working_drupal site, I got past the database permissions problem and was presented with my usual screen for login and such. When I tried to login as admin with the proper password, nothing happened. I mean to say, the screen flickered momentarily, but then brought me back to the exact same page where the app was waiting for me to login. When I tried to login as admin with the wrong password, Drupal knew I had provided the wrong password. So it appears the query (or whatever) for login is working, but the application will not allow me to login.

If anyone could help me out on this, I would GREATLY appreciate it! Thanks in advance!

Chris Ivey

Affiliated Computer Services
Infrastructure Management Senior Analyst
(Complete Drupal Newbie)

Comments

ashwad’s picture

Setting of multiple drupal sites on a single source code:

Steps to be followed.Assume a folder named testsite is created.

1.create a folder under sites directory.If u want to access your new site as http://testsite then name the folder as testsite.Then copy the settings.php file in the sites/default directory and paste it in the folder created above.

2.
Case1:
Launching multiple sites with the same database.
In settings.php file
Step1:Let the $db_url as it is.Type “testsite_ “ the $db_prefix .So a new site is created by sharing a single databse,but the tables for the new site have the prefix “testsite_”.
Step2: Change the $base_url to http://testsite

Case2:
Launching multiple sites with separate database.
In settings.php
Step1:Create a database.Enter the database name in $db_url.
Step2: Change the $base_url to http://testsite

3.In apache,add the following line in httpd.conf file.

DocumentRoot "C:\ProgramFiles\ApacheSoftwareFoundation\Apache2.2\htdocs\Drupal"
ServerName testsite

4.search for hosts file in C:\ and type ip of the localhost and name it as testsite.

5.Open IE and give the url as http://testsite or http://testsite/install.php

civey’s picture

Thanks for your response, Vijei. I pretty much followed those exact steps per the handbook referenced in my original post (please see http://drupal.org/node/120647 for the steps I followed). I can't seem to see what else I am missing here. Is there something that I need to do that are not detailed in those directions? Thanks again!

Chris Ivey

Affiliated Computer Services
Infrastructure Management Senior Analyst
(Complete Drupal Newbie)

cog.rusty’s picture

This must be a user session problem, that is, Drupal's login works but it does not recognize you as the one who logged in. It has come up a few times with local sites recently. Unfortunately, after discussing and trying a few things people don't report back whether and how it was solved, so I am not sure what exactly the problem is, and I have never been able to reproduce it myself.

Perhaps it has to do with the cookie domain when the domain contains no dots. The reason that I am suspecting this are these lines in the /includes/bootstrap.inc file (only in Drupal 5.2):

  if ($cookie_domain) {
    // If the user specifies the cookie domain, also use it for session name.
    $session_name = $cookie_domain;
    ....
    ....
  // Per RFC 2109, cookie domains must contain at least one dot other than the
  // first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
  if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
    ini_set('session.cookie_domain', $cookie_domain);
  }
  session_name('SESS'. md5($session_name));

The $cookie_domain variable mentioned here is an optional variable which you can set in the settings.php file (only in Drupal 5.2). What is called "the first dot" here is an additional dot which is added in front of the cookie domain, not an existing dot.

So, try to set $cookie_domain = 'working_drupal'; in settings.php and see if that helps.

A second try is to reconfigure your domain name and set it, for example, to http://working.drupal so that it contains a dot.

Reporting back any success or failure would be useful for others.

--------------- Edited to add:

Another possible problem: Also check the URL and the menu links of your current page, either when you hover your mouse or when you click on them, to see if they take you to any unexpected paths, such as "cgi-bin" or something else. In that case you may need to set the optional $base_url in settings.php.

-------------- A second update

I remembered that someone reported that he never solved this but that he can login by trying two times in a row.

civey’s picture

Thanks, cog.rusty, for your reply to my question. I tried all of the above except making it a dot instead of an underscore. It still does not work. Here is what my settings.php in sites/working_drupal now looks like after making the recommended changes:

/**
 * We try to set the correct cookie domain. If you are experiencing problems
 * try commenting out the code below or specifying the cookie domain by hand.
 */
//if (isset($_SERVER['HTTP_HOST'])) {
  //$domain = '.'. preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']);
  // Per RFC 2109, cookie domains must contain at least one dot other than the
  // first. For hosts such as 'localhost', we don't set a cookie domain.
  //if (count(explode('.', $domain)) > 2) {
  //  ini_set('session.cookie_domain', $domain);
  //}
//}
$cookie_domain = 'working_drupal';

$session_name = $cookie_domain;
ini_set('session.cookie_domain', $cookie_domain);

I checked all my URLs, and none of them point to cgi-bin or anything crazy like that. I also tried logging in twice in a row (or more, actually, as I tried like 4 times) and that still did not work either.

(Oh, and for what it's worth - if you download and install the package on a Windows machine as outlined in the Handbook, and follow the steps on part c, you will be able to reproduce the issue... << grin >>)

Thanks, and I look forward to hearing more!

Chris Ivey

Affiliated Computer Services
Infrastructure Management Senior Analyst
(Complete Drupal Newbie)

cog.rusty’s picture

What you posted is not from Drupal 5.2 settings.php file. These things have been moved into the code. Compare:

http://cvs.drupal.org/viewvc.py/drupal/drupal/sites/default/settings.php...

You are probably using Drupal 5.1? Or is it only a mismatched settings.php file? The $cookie_domain variable was not available in settings.php in 5.1, and I don't know of a $session_name available in either.

Hmm... Looking closer, if you are using 5.1 then your code probably does everything which should be done, by using $cookie_domain as a local variable of yours. The only thing that the code would do differently is that it would add a dot in front of session.cookie_domain, which would make it '.working_drupal'. Second hmm... or doesn't it set the session name properly? A visit to your session table in the database may reveal something.

I do have a working local multisite installation on Windows, but I was OK with both 5.1 and 5.2, so I can't really test the problem.

Between attempts to change the cookie domain, it could be a good idea to clear the browser's cookies.

civey’s picture

OK, I deleted my sites created with the directions on the page, and am going to move on to the instructions in the comments... maybe something there makes more sense... thanks again, cog! I will let you know if I come across the same issues...

Chris Ivey

Affiliated Computer Services
Infrastructure Management Senior Analyst
(Complete Drupal Newbie)

civey’s picture

For some reason, either PHP or Drupal does not like the underscore character in the site name. I changed "alldot_drupal" to "alldot", and "working_drupal" to "working", and the problems went away! Thanks again for all your assistance!

Chris Ivey

Affiliated Computer Services
Infrastructure Management Senior Analyst
(Complete Drupal Newbie)

ashwad’s picture

Hi,
I couldn't reply you as i was on leave yesterday.Anyhow you got it right.that's great.all the very best to explore new things in drupal.