Step 1: Download and uncompress Drupal
You can download and uncompress Drupal by following the steps on the Download and uncompress Drupal page of the Installation guide, as this step does not differ from a normal installation.
Step 2: Set up your hosts file
Add the following lines to /etc/hosts:
127.0.0.1 mysite1.localhost
127.0.0.1 mysite2.localhost
Step 3: Set up Virtual Hosts
Add the following code to /etc/apache2/httpd.conf:
<VirtualHost *:80> DocumentRoot /var/www/html ServerName localhost <VirtualHost *:80> DocumentRoot /var/www/drupal ServerName mysite1.localhost <VirtualHost *:80> DocumentRoot /var/www/drupal ServerName mysite2.localhost
After this, restart Apache: sudo /etc/init.d/apache2 restart
Step 4: Set up your databases
Create two databases. Name one of them mysite1 and the other mysite2.
Step 5: Set up your sites folders
1. From the command prompt, navigate to /var/www/drupal/sites/ or wherever you have your sites folder installed.
2. 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:
3. Copy the default directory to create your new site directories:
sudo cp -a default/ mysite1.localhost sudo cp -a default/ mysite2.localhost
4. 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 mysite1.localhost/default.settings.php mysite1.localhost/settings.php sudo mv mysite2.localhost/default.settings.php mysite2.localhost/settings.php sudo chmod a+w mysite1.localhost/settings.php sudo chmod a+w mysite2.localhost/settings.php
Step 6: Run the installation script for your sites
In a web browser, visit http://mysite1.localhost/install.php and follow the instructions found on the Run the installation script page of the Installation guide. Repeat for http://mysite2.localhost/install.php.
Step 8: Remove write permissions from your sites' settings.php files
You don't really need to do this, since this is only a development environment, so we're not really concerned about security. Nevertheless, it's a good habit to get into: From the command prompt, navigate to /var/www/drupal/sites and remove the write permissions for the settings.php files: sudo chmod a-w mysite1.localhost/settings.php sudo chmod a-w mysite2.localhost/settings.php
Step 9: You're done!
You can visit your sites at: http://mysite1.localhost/index.php http://mysite2.localhost/index.php
Important Points
-
The themes/modules which are under yourproject/all/themes or yourproject/all/modules, will share among all the sites.
-
If you want a theme for the particular site, say
Example : mysite1.localhost is under yourproject/site/. You need create themes folder inside mysite1.localhost and place all the your custom or contributed themes in THEMES directory. mysite1.localhost/themes/yourthemes similarly, for modules mysite1.localhost/modules/yourmodules.