Example 1:
- Create dns entries for the sites ( or use hosts file for testing)
- Create vhosts in Apache configuration file and restart Apache:
Listen 80
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName localhost:80
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName www.site1.local:80
DocumentRoot "C:/Program Files/xampp/htdocs"
ServerName www.site2.local:80
- Create folder sites under drupal/sites
- Copy settings.php from drupal/sites/default to each site folder. Modify $db_url and $db_prefix in settings.php in each site folder.
$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.
- Open your web browser and point to the install.php file for each site
http://www.site2.local/drupal/install.php
- Edit the /etc/hosts and add the following lines
10.123.11.61 www.site1.local
10.123.11.61 www.site2.local
- Your new sites are ready using a single code base, single db user and single or multiple db’s.
http://www.site2.local/drupal/
Example 2:
- Create folder sites under drupal/sites
- www.site1.local www.site2.local
- /etc/apache2/sites-available/site1.local will be
DocumentRoot /var/www/drupal613multisite
ServerName www.site1.local
ErrorLog /var/log/apache2/error.log
- Make link to ln -s /etc/apache2/sites-available/site1.local /etc/apache2/sites-enabled/site1.local
- /etc/apache2/sites-available/site2.local will be
DocumentRoot /var/www/drupal613multisite
ServerName www.site2.local
ErrorLog /var/log/apache2/error.log
ServerName www.site2.local
ErrorLog /var/log/apache2/error.log
- Make link to ln -s /etc/apache2/sites-available/site2.local /etc/apache2/sites-enabled/site2.local
- Edit the /etc/hosts and add the following lines
10.123.11.61 www.site1.local
10.123.11.61 www.site2.local
- In /etc/apache2/sites-available/default add the following line in top of the file
- Restart apache server.
- Run http://www.site1.local and http://www.site2.local
No comments:
Post a Comment