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 existing000-default.conffile to a new filetestsite.localhostand make the changes inside the file as mentioned below.
<\virtualhost> DocumentRoot /var/www/drupal ServerName testsite.localhost <\/virtualhost>
- Do the same thing for
testsite2.localhostalso.
Google Ad 1
- After this, restart Apache.
sudo /etc/init.d/apache2 restart
Set up your databases
- Create the two databases
testsiteand the othertestsite2.
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
Google Ad 2
- Rename the
default.settings.phpfiles tosettings.phpand 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 thesettings.phpfile 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 replacetestsitewithtestsite2.
Run the installation script for your sites
- In a web browser, visit
http://testsite.localhost/install.php.
Google Ad 3
Remove write permissions from your sites settings.php files
- From the command prompt, navigate to
/var/www/drupal/sitesand remove the write permissions for thesettings.phpfiles:
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 below urls
http://testsite.localhost/index.php
http://testsite2.localhost/index.php
Thanks for reading the article, for more drupal related articles read and subscribe to peoples blog articles.








![Samsung Galaxy Tab S9 FE [Smartchoice], RAM 6 GB, ROM 128 GB Expandable, S Pen in-Box, Wi-Fi, IP68 Tablet, Gray Samsung Galaxy Tab S9 FE [Smartchoice], RAM 6 GB, ROM 128 GB Expandable, S Pen in-Box, Wi-Fi, IP68 Tablet, Gray](https://m.media-amazon.com/images/I/71BM3TBipEL._SX679_.jpg)


