1

I have a working Drupal 6 using a shared Drupal install on a shared Linux server. I've just installed D7. I'm not sure if sites.php is set up correctly (see below). And I can't find good information on this sites.php file to be sure I set it up correctly. This Drupal.org page describes the correct installation situation, but sadly does not mention sites.php (>_<) This Drupal forum poster has the same "Server Not Found" error, but shows completely wrong sites.php example--the set up is not clear.

Is sites.php do the same thing that a symbolic link folder did in Drupal 6. Can I ignore this file?

My sites.php file,

 $sites['mondo7'] = 'mondo7.mydomain.com';

and I tried it the other way,

 $sites['mondo7.mydomain.com'] = 'mondo7';

Both show up "Server Not Found".

3

sites.php exists so you can fake out the normal multi-site operation, like mapping 'localhost' to 'foo.mysiteroolz.com'. Ideally you wouldn't use it in a production server.

In a live-to-the-internet site, you don't want to have sites.php (unless you specifically know why you do), and you want your subdomain to resolve to the same IP and directory as the domain. Then just have a subdirectory in /sites. So:

drupal/sites/default/ will have settings.php and files for mydomain.com

drupal/sites/mondo7.mydomain.com/ will have settings.php and files for mondo7.mydomain.com.

Then in your dev setup, you'd have a sites.php file that says something like 'localhost' => 'mondo7.mydomain.com' This tells Drupal which site directory gets the attention when a request comes for localhost.

HTH.

  • ?? I have multiple drupal sites in each sites folder for Drupal 6 and Drupal 7. Thus one D6 install and one D7 install on the remote test server. Each subdomain needs to resolve to the site folder in sites. how does localhost resolve this and not get greedy? – xtian Jan 14 '12 at 0:21
  • You use sites.php to tell Drupal which incoming request domain (such as 'localhost') maps to which /sites folder (such as '/sites/mondo7.example.com'). In a production setup, you probably don't want this, but in a dev setup you might very well want it. – paul-m Jan 14 '12 at 5:47
  • Are you assuming the "dev setup" means my same workhorse computer or localhost, and the production setup is outside my LAN? Then are you suggesting the sites.php does not work on a remote server? Should I use the symbolic linked folder setup? Is the trouble with my D7 setup that I am using both sites.php and symbolic folders? – xtian Jan 14 '12 at 23:08
  • site.php will only be a problem if it aliases incoming requests in a way that you don't want. It exists to help people develop multi-site Drupal sites on local machines. As a rule of thumb, there should be no symbolic links in your multi-site setup in order to make Drupal happy. You might need them to make your hosting setup happy in some way, but not Drupal. – paul-m Jan 14 '12 at 23:38
0

The purpose of the site.php file is documented in example.site.php (the file that comes with the Drupal installation files).

Drupal searches for an appropriate configuration directory based on the website's hostname and pathname. A detailed description of the rules for discovering the configuration directory can be found in the comment documentation in 'sites/default/default.settings.php'.

This file allows you to define a set of aliases that map hostnames and pathnames to configuration directories. These aliases are loaded prior to scanning for directories, and they are exempt from the normal discovery rules. The aliases are defined in an associative array named $sites, which should look similar to the following:

$sites = array( 'devexample.com' => 'example.com', 'localhost.example' => 'example.com', );

The above array will cause Drupal to look for a directory named "example.com" in the sites directory whenever a request comes from "example.com", "devexample.com", or "localhost/example". That is useful on development servers, where the domain name may not be the same as the domain of the live server. Since Drupal stores file paths into the database (files, system table, etc.) this will ensure the paths are correct while accessed on development servers.

If you don't have a development site, you should not use the site.php file, and that is the reason the page you read doesn't have any reference to that file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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