Monday, 20 December 2010

Multi-site how-tos


Multi-site how-tos


Drupal 5.1 Multi Site Configuration

Example:
1. Create dns entries for the sites ( or use hosts file for testing)
2. Create vhosts in Apache configuration file and restart Apache:
Listen 80
<VirtualHost *:80>
    DocumentRoot "C:/Program Files/xampp/htdocs"
    ServerName localhost:80
</VirtualHost>

<VirtualHost www.site1.local:80>    DocumentRoot "C:/Program Files/xampp/htdocs"
    ServerName www.site1.local:80
</VirtualHost>
<VirtualHost
www.site2.local:80>    DocumentRoot "C:/Program Files/xampp/htdocs"
    ServerName www.site2.local:80
</VirtualHost>
3. Create folder sites under drupal/sites
Note: Each site folder can have a file, tmp, modules and themes subfolders.
4. Copy settings.php from drupal/sites/default to each site folder.
5. Modify $db_url and $db_prefix in settings.php in each site folder.
For www.site1.local: Single database and db user.
$db_url = 'mysql://drupal:drupal@localhost/drupal';
$db_prefix = 'site1_';
For www.site2.local: Single database and single db user.
$db_url = 'mysql://drupal:drupal@localhost/drupal';
$db_prefix = 'site2_';
For www.site1.local: Multiple databases and single db user.
$db_url = 'mysql://drupal:drupal@localhost/site1';
$db_prefix = '';
For www.site2.local: Multiple databases and single db user.
$db_url = 'mysql://drupal:drupal@localhost/site2';
$db_prefix = '';
Note: Always use the same db user (the one that you used to install drupal for the first time) independently if you want to have a single or multiples db’s.
6. Open your web browser and point to the install.php file for each site
7. Your new sites are ready using a single code base, single db user and single or multiple db’s.

No comments:

Post a Comment

Source base installation of php, mysql and apache in ubuntu/ linux

Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source In the last post, I described the method to install a LAMP ser...