Yup, you may call it “multisite installation”. That means, you may run more than one site with only a single Drupal core.
Step 1: Create a new virtual host
To run multiple sites, we need to create Virtual Hosts in our machine. For example, If I type http://mydrupal I’ll be taken to my drupal site. For that, first we need to change ‘/etc/hosts’ file. Run following command in terminal and provide root password when promted:
gksudo gedit /etc/hosts
Next, add following line to the file and save the file:
Step 2: Restart networking interface
Type in terminal:
sudo /etc/init.d/networking restart
Step 3: Configure Apache2
For the easiest way, go the directory /etc/apache2/sites-enabled. Here, you will see a file named something like 000-default (or whatever), open it for editing. Place following code for opening it for editing:
gksudo gedit /etc/apache2/sites-enabled/000-default
Now, you need to create a <VirtualHost> directive:
<VirtualHost 127.0.0.4:80> ServerAdmin [email@example.com] DocumentRoot /path-to-your-drupal/ ServerName mydrupal <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /path-to-your-drupal/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ RewriteEngine On RewriteOptions inherit </VirtualHost>
Note that <VirtualHost 127.0.0.4:80> should contain the IP address you provided in step 1, we chose “127.0.0.4” since it will be pointing to your own machine. Also, note the line ServerName mydrupal – here “mydrupal” is the name we chose in step 1.
Step 4: Restart Apache2
Type in terminal:
sudo /etc/init.d/apache2 restart
Yup, that’s all!
Type http://mydrupal in your browser, you will see the new drupal site running! Now you can create all the necessary files (database settings, modules, themes etc.) under sites folder of your Drupal path. Copy the path-to-drupal/sites/default folder and rename it to path-to-drupal/sites/mydrupal.
Next, you can (should):
- Edit “path-to-drupal/sites/mydrupal/settings.php” – for database settings. Change database username, password, database name etc.
- Create a new database if necessary, using PHPMyAdmin, or whatever.
- Run http://mydrupal/install.php for installing new database, etc.