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.conf
file to a new filetestsite.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.
Google Ad 1
- After this, restart Apache.
sudo /etc/init.d/apache2 restart
Set up your databases
- Create the two databases
testsite
and 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.php
files tosettings.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 thesettings.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 replacetestsite
withtestsite2
.
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/sites
and remove the write permissions for thesettings.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 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.