1

I know how to install a single instance of Drupal very well but I want to create a number of sub-sites under my Drupal installation. My file structure is as follows:

drupal7_main
 -sites
   --drupal7_sub1
    settings.php
   --drupal7_sub2
    settings.php

I'm developing on my localhost and the plan is to duplicate the structure on the production server.

However, only drupal7_main works. When I visit localhost/drupal7_main, Drupal is ready and configurable as usual; when I visit localhost/drupal7_sub1, I get the following error.

Not Found
The requested URL /drupal7_sub1 was not found on this server.

I get the same for drupal7_sub2.

I'm trying to learn this process and would appreciate some help.

0

3 Answers 3

0

You need to create symbolic links in order that your drupal7_sub1 and drupal7_sub2 directories works. Those symlinks needs to target your drupal7_main directory.

To create a symlink, open a commandline tool and execute following commands (if your on a Windows machine). You need to put the correct paths depending your localhost configuration.

First go to root directory of your localhost

cd C:/wampp/htdocs/

Create symlink for each subwebsite (drupal7_sub1, drupal7_sub2)

mklink /D drupal7_sub1 C:/wampp/htdocs/drupal7_main
mklink /D drupal7_sub2 C:/wampp/htdocs/drupal7_main

Executing this will already give you a result when visiting localhost/drupal7_sub1. If everything went well, you should see your localhost/drupal7_main website.

Because your working with a localhost URL (and not real domain name, can be a development URL only existing on local, i.e. dev.yourproject.com), you need to slightly adapt your folder structure in order that each subwebsite uses its own settings.php and file folder for the files (uploads, css, ctools, js).

You need to prefix your subfolders under drupal7_main/sites/ with localhost.

drupal7_main/sites/drupal7_sub1 --> drupal7_main/sites/localhost.drupal7_sub1
drupal7_main/sites/drupal7_sub2 --> drupal7_main/sites/localhost.drupal7_sub2
10
  • Thanks for your answer. Can you offer some more help? Having followed your instructions I get a "Forbidden - You don't have permission to access /drupal7_sub1/ on this server." when I visit localhost/drupal7_sub1
    – sisko
    Oct 10, 2013 at 19:23
  • When you verify the log files (error.log) of your Apache, what do you have as error message? Things that you can you check is that the file system path exists and points to the correct drupal7_main path + in your Apache configuration (httpd) you have 'Order allow,deny, Allow from all, AllowOverride all' in your <Directory> definition. Oct 10, 2013 at 20:53
  • I get the following error in my error-log: [error] [client 127.0.0.1] File does not exist: /var/www/drupal7_sub1
    – sisko
    Oct 11, 2013 at 14:19
  • It seems the symbolic link is not correct. Are you on a unix machine? Try to create symlink like this 'ln -s /var/www/drupal7_main /var/www/drupal7_sub1'. When you do a 'ls -la', you see that the folder /var/www/drupal7_sub1 points to /var/www/drupal7_main? Oct 12, 2013 at 9:36
  • Did you managed to get it working ? Oct 19, 2013 at 7:45
0

You need to configure your httpd.conf file

in your case you need to add this in your httpd.conf (assuming you using lamp)

<VirtualHost *:80>
 #DocumentRoot /opt/lampp/htdocs/html
 #ServerName localhost
</VirtualHost>

<VirtualHost *:80>
 ServerName drupal7_sub1
 ServerAlias drupal7_sub1
 DocumentRoot  /opt/lampp/htdocs/'site-root-folder' 
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
 ServerName drupal7_sub2
 ServerAlias drupal7_sub
 DocumentRoot /opt/lampp/htdocs/'site-root-folder'
</VirtualHost>`
0

All your new sites vhost should be pointing to the drupal root installation where the index file lives and the entry point for all your sites, not to the site1 folder. "DocumentRoot /var/www/multisite" this should be the same for all your sites.

With multi-site a approach you can shared modules between sites (those in all folder), have different modules per site, you can have different databases per site and share tables between them.

Your drupal sites are going to share the same code base, One drupal core for everyone.

This can be useful https://drupal.org/documentation/install/multi-site This is also here How do I setup multiple sites with one database in Drupal 7 (or) Multisite Apache configuration with Drupal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.