Drupal Multisite development environment Configuration in Ubuntu14

Read Article
Pause
Resume
Stop
Drupal Multisite development environment Configuration in Ubuntu14

Prerequisite Requires a working drupal installation

Set up your hosts file Add the following lines to /etc/hosts:

127.0.0.1    testsite.localhost
127.0.0.1    testsite2.localhost

Set up Virtual Hosts

Add the following code to /etc/apache2/sites-available:

Goto to the folder /etc/apache2/sites-available, copy the existing 000-default.conf file to a new file testsite.localhost and make the changes inside the file as mentioned below.

<\virtualhost>
    DocumentRoot /var/www/drupal
    ServerName testsite.localhost
<\/virtualhost>

Do the same thing for testsite2.localhost also.

After this, restart Apache:

sudo /etc/init.d/apache2 restart

Set up your databases

Create the two databases testsite and the other testsite2.

Set up your sites folders

From the command prompt, navigate to /var/www/drupal/sites/ or wherever you have your sites folder installed.

The default directory will serve as a template for our other sites. Create a writable files directory in the default directory to make sure every one of your site folders get this directory:

sudo mkdir -pm 777 default/files

Copy the default directory to create your new site directories:

sudo cp -a default/ testsite.localhost

sudo cp -a default/ testsite2.localhost

Rename the default.settings.php files to settings.php and change the permissions to make them writable, so that the web server can access them in step 7:

sudo mv testsite.localhost/default.settings.php testsite.localhost/settings.php

sudo mv testsite2.localhost/default.settings.php testsite2.localhost/settings.php

sudo chmod a+w testsite.localhost/settings.php

sudo chmod a+w testsite2.localhost/settings.php

Configure your sites to use the appropriate databases

In the /var/www/drupal/sites/testsite.localhost/ directory, edit the settings.php file as follows

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'testsite',
      'username' => 'testuser',
      'password' => 'password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

Repeat for /var/www/drupal/sites/testsite2.localhost/, except replace testsite with testsite2.

Run the installation script for your sites

In a web browser, visit http://testsite.localhost/install.php.

Remove write permissions from your sites settings.php files

From the command prompt, navigate to /var/www/drupal/sites and remove the write permissions for the settings.php files:

sudo chmod a-w testsite.localhost/settings.php

sudo chmod a-w testsite2.localhost/settings.php

You're done!

You can visit your sites at:

http://testsite.localhost/index.php

http://testsite2.localhost/index.php

Thank you :)

Comments

Scroll to Top
We Need Your Consent
By clicking “I Accept Cookies”, you agree to the storing of cookies on your device to enhance site navigation & analyze site usage.
I Accept Cookies