5

I am trying to do multi-site the following way:

http://domain.com/site1

http://domain.com/site2

sites.php:

 $sites['domain.com.site1'] = 'default';
 $sites['domain.com.site2'] = 'site2';

I then went into my drupal root and did:

ln -s . site1
ln -s . site2

Is this the correct way of doing this? It appears to work, but I am not sure if symlinking is the proper way.

2
  • Shouldn't that be: $sites['domain.com.site1'] = 'site1'; (not default) $sites['domain.com.site2'] = 'site2'; ? – therobyouknow Mar 24 '14 at 23:21
  • Check out: drupal.org/documentation/install/multi-site which answers your question. From # 5: "Make symbolic links if you are using a subdirectory such as example.com/subdir and not a subdomain such as subd.example.com (see the subdirectory multi-site section below for details). " – Screenack Aug 4 '15 at 10:26
3

Yes- you did this right :)

cp example.sites.php as sites.php, set the sites array, set the symlink, and you're set!

5
  • Are there are security issues with the fact that you can so /site1/site1/site1...? – Chris Muench Jul 24 '13 at 3:21
  • I'm not quite sure what you mean- all sites should be located in the /sites/ directory and have a unique settings.php... This shouldn't pose a security risk. – adam_bear Jul 24 '13 at 3:56
  • I mean I can do domain.com/site1/site1/site1 because of the symlink to its parent directory. – Chris Muench Jul 24 '13 at 12:57
  • You're still only accessing the parent directory- how would this pose a risk? – adam_bear Jul 24 '13 at 16:51
  • @ChrisMuench security is what I was thinking too when I saw this. I haven't spent time on it, but I expect there very likely are implications here. Check rewrite rules for things like protecting private file directories carefully, and post any worrying findings. Circular symlinks are almost always a bad idea. – mc0e Dec 17 '14 at 6:51
0

You can set the sites array in sites.php as:

$sites['multi.devs'] = 'multi.dev';
$sites['sub1.multi.devs'] = 'multi.devs';
$sites['sub2.multi.devs'] = 'multi.devs';

and in your hosts file you can set the hostname as

127.0.0.1       multi.devs
127.0.0.1       sub1.multi.devs
127.0.0.1       sub2.multi.devs

Also need to entry them in httpd-vhost.conf file. Like:

<VirtualHost *:80>
    DocumentRoot "projects/drupal_multi/"
    ServerName   multi.devs
    ErrorLog    "logs/error.log"
    CustomLog   "logs/access.log" common
</VirtualHost> 

You need to do this for each of sub site. DocumentRoot will be the same the server name will be change for each of them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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